diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-21 16:27:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-21 16:27:34 +0200 |
commit | 5694c0a4529334756f2b914ad67408df199551dc (patch) | |
tree | 38daa2e27d6049ca7a808af642eb82a29c9d2886 /odb/sqlite/database.ixx | |
parent | 1bf4678c29b6e51396c18582b270254d1bd2cddc (diff) |
Add odb::connection class
This abstract class represents a connection to the database. One can
use it to start a transaction or to execute a native statement out
of a transaction.
Before we had concrete connection classes in the database runtime
libraries (e.g., odb::mysql::connection). Now these classes derive
from odb::connection.
Diffstat (limited to 'odb/sqlite/database.ixx')
-rw-r--r-- | odb/sqlite/database.ixx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/odb/sqlite/database.ixx b/odb/sqlite/database.ixx index 7e34e01..f78d659 100644 --- a/odb/sqlite/database.ixx +++ b/odb/sqlite/database.ixx @@ -7,10 +7,32 @@ namespace odb { namespace sqlite { - inline details::shared_ptr<database::connection_type> database:: + inline connection_ptr database:: connection () { - return factory_->connect (); + // Go through the virtual connection_() function instead of + // directly to allow overriding. + // + return connection_ptr ( + static_cast<sqlite::connection*> (connection_ ())); + } + + inline transaction_impl* database:: + begin () + { + return connection ()->begin (); + } + + inline transaction_impl* database:: + begin_immediate () + { + return connection ()->begin_immediate (); + } + + inline transaction_impl* database:: + begin_exclusive () + { + return connection ()->begin_exclusive (); } } } |