diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-28 16:53:54 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-28 16:53:54 +0200 |
commit | 44a26d189e186ac10c4a80c4dbb68d65927b12a9 (patch) | |
tree | 4bf37b4283c4b51c5a6568cfb540e176f6bfa520 /odb/pgsql/connection-factory.hxx | |
parent | b405fdd235a7dcb40423229af033abd4687c72b2 (diff) |
Add create() hook to connection factories
This will allow the user to either establish the connection themselves
(using the handle c-tor) and/or configure the connection post-creation.
Diffstat (limited to 'odb/pgsql/connection-factory.hxx')
-rw-r--r-- | odb/pgsql/connection-factory.hxx | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/odb/pgsql/connection-factory.hxx b/odb/pgsql/connection-factory.hxx index 8a7b9c8..936a488 100644 --- a/odb/pgsql/connection-factory.hxx +++ b/odb/pgsql/connection-factory.hxx @@ -105,13 +105,12 @@ namespace odb connection_pool_factory (const connection_pool_factory&); connection_pool_factory& operator= (const connection_pool_factory&); - private: + protected: class pooled_connection: public connection { public: - // NULL pool value indicates that the connection is not in use. - // - pooled_connection (database_type&, connection_pool_factory*); + pooled_connection (database_type&); + pooled_connection (database_type&, PGconn*); private: static bool @@ -121,19 +120,30 @@ namespace odb friend class connection_pool_factory; shared_base::refcount_callback callback_; + + // NULL pool value indicates that the connection is not in use. + // connection_pool_factory* pool_; }; friend class pooled_connection; - typedef std::vector<details::shared_ptr<pooled_connection> > connections; - private: + typedef details::shared_ptr<pooled_connection> pooled_connection_ptr; + typedef std::vector<pooled_connection_ptr> connections; + + // This function is called whenever the pool needs to create a new + // connection. + // + virtual pooled_connection_ptr + create (); + + protected: // Return true if the connection should be deleted, false otherwise. // bool release (pooled_connection*); - private: + protected: const std::size_t max_; const std::size_t min_; |