diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-09 18:14:37 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-09 18:14:37 +0200 |
commit | fc70be62d8698496a20b6947d102757f426c5b3e (patch) | |
tree | 92610ee68abf5a1fcc40e8717c4011628865c601 /odb/pgsql/connection-factory.hxx | |
parent | f5f515acc2b926eb838b82b457f6b5979db5f309 (diff) |
Make database class move-constructible
This means it can be returned by value from a function in C++11.
Diffstat (limited to 'odb/pgsql/connection-factory.hxx')
-rw-r--r-- | odb/pgsql/connection-factory.hxx | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/odb/pgsql/connection-factory.hxx b/odb/pgsql/connection-factory.hxx index a0009ff..0ee2197 100644 --- a/odb/pgsql/connection-factory.hxx +++ b/odb/pgsql/connection-factory.hxx @@ -25,42 +25,17 @@ namespace odb { namespace pgsql { - class LIBODB_PGSQL_EXPORT connection_factory - { - public: - virtual connection_ptr - connect () = 0; - - public: - typedef pgsql::database database_type; - - virtual void - database (database_type&) = 0; - - virtual - ~connection_factory (); - }; - class LIBODB_PGSQL_EXPORT new_connection_factory: public connection_factory { public: - new_connection_factory () - : db_ (0) - { - } + new_connection_factory () {} virtual connection_ptr connect (); - virtual void - database (database_type&); - private: new_connection_factory (const new_connection_factory&); new_connection_factory& operator= (const new_connection_factory&); - - private: - database_type* db_; }; class LIBODB_PGSQL_EXPORT connection_pool_factory: @@ -86,7 +61,6 @@ namespace odb min_ (min_connections), in_use_ (0), waiters_ (0), - db_ (0), cond_ (mutex_) { // max_connections == 0 means unlimited. @@ -111,8 +85,8 @@ namespace odb class LIBODB_PGSQL_EXPORT pooled_connection: public connection { public: - pooled_connection (database_type&); - pooled_connection (database_type&, PGconn*); + pooled_connection (connection_pool_factory&); + pooled_connection (connection_pool_factory&, PGconn*); private: static bool @@ -121,11 +95,7 @@ namespace odb private: 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_; + shared_base::refcount_callback cb_; }; friend class pooled_connection; @@ -152,7 +122,6 @@ namespace odb std::size_t in_use_; // Number of connections currently in use. std::size_t waiters_; // Number of threads waiting for a connection. - database_type* db_; connections connections_; details::mutex mutex_; |