aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/connection-factory.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/sqlite/connection-factory.hxx')
-rw-r--r--odb/sqlite/connection-factory.hxx52
1 files changed, 34 insertions, 18 deletions
diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx
index 8166fc4..04f91bf 100644
--- a/odb/sqlite/connection-factory.hxx
+++ b/odb/sqlite/connection-factory.hxx
@@ -61,15 +61,12 @@ namespace odb
single_connection_factory (const single_connection_factory&);
single_connection_factory& operator= (const single_connection_factory&);
- private:
+ protected:
class single_connection: public connection
{
public:
- // NULL factory value indicates that the connection is not in use.
- //
- single_connection (database_type&,
- int extra_flags,
- single_connection_factory*);
+ single_connection (database_type&, int extra_flags);
+ single_connection (database_type&, sqlite3*);
private:
static bool
@@ -79,21 +76,32 @@ namespace odb
friend class single_connection_factory;
shared_base::refcount_callback callback_;
+
+ // NULL factory value indicates that the connection is not in use.
+ //
single_connection_factory* factory_;
};
friend class single_connection;
- private:
+ typedef details::shared_ptr<single_connection> single_connection_ptr;
+
+ // This function is called when the factory needs to create the
+ // connection.
+ //
+ virtual single_connection_ptr
+ create ();
+
+ protected:
// Return true if the connection should be deleted, false otherwise.
//
bool
release (single_connection*);
- private:
+ protected:
database_type* db_;
details::mutex mutex_;
- details::shared_ptr<single_connection> connection_;
+ single_connection_ptr connection_;
};
// Create a new connection every time one is requested.
@@ -167,15 +175,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&,
- int extra_flags,
- connection_pool_factory*);
+ pooled_connection (database_type&, int extra_flags);
+ pooled_connection (database_type&, sqlite3*);
private:
static bool
@@ -185,19 +190,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_;
int extra_flags_;