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.hxx69
1 files changed, 68 insertions, 1 deletions
diff --git a/odb/sqlite/connection-factory.hxx b/odb/sqlite/connection-factory.hxx
index b665625..b410997 100644
--- a/odb/sqlite/connection-factory.hxx
+++ b/odb/sqlite/connection-factory.hxx
@@ -23,7 +23,42 @@ namespace odb
{
namespace sqlite
{
- // Share a single connection.
+ // Share a single connection in a guaranteed serial database access.
+ //
+ // For example, a single-threaded application that executes all the
+ // operations via the database instance without messing with multiple
+ // connections/transactions would qualify.
+ //
+ class LIBODB_SQLITE_EXPORT serial_connection_factory:
+ public connection_factory
+ {
+ public:
+ serial_connection_factory () {}
+
+ virtual connection_ptr
+ connect ();
+
+ virtual void
+ database (database_type&);
+
+ virtual
+ ~serial_connection_factory ();
+
+ private:
+ serial_connection_factory (const serial_connection_factory&);
+ serial_connection_factory& operator= (const serial_connection_factory&);
+
+ protected:
+ // This function is called when the factory needs to create the
+ // connection.
+ //
+ virtual connection_ptr
+ create ();
+
+ connection_ptr connection_;
+ };
+
+ // Share a single connection potentially between multiple threads.
//
class LIBODB_SQLITE_EXPORT single_connection_factory:
public connection_factory
@@ -198,6 +233,38 @@ namespace odb
details::mutex mutex_;
details::condition cond_;
};
+
+ class LIBODB_SQLITE_EXPORT default_attached_connection_factory:
+ public attached_connection_factory
+ {
+ public:
+ explicit
+ default_attached_connection_factory (const connection_ptr& main)
+ : attached_connection_factory (main) {}
+
+ using attached_connection_factory::database; // Accessor.
+
+ virtual void
+ database (database_type&);
+
+ virtual connection_ptr
+ connect ();
+
+ virtual void
+ detach ();
+
+ // Active object interface.
+ //
+ virtual void
+ clear ();
+
+ virtual
+ ~default_attached_connection_factory ();
+
+ protected:
+ static void
+ translate_statement (std::string&, const char*, std::size_t, connection&);
+ };
}
}