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 | 5b6649e6f7dd256147b48197a007c23001cef647 (patch) | |
tree | debffbb24e00bc485f9675cbc5be08ec1cc8eea9 /odb/transaction.hxx | |
parent | 1e63b60696f2e3012221e3bf6430a0d66ce1ba34 (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/transaction.hxx')
-rw-r--r-- | odb/transaction.hxx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/odb/transaction.hxx b/odb/transaction.hxx index 17487b2..c2b1f77 100644 --- a/odb/transaction.hxx +++ b/odb/transaction.hxx @@ -20,6 +20,7 @@ namespace odb { public: typedef odb::database database_type; + typedef odb::connection connection_type; explicit transaction (transaction_impl*); @@ -40,6 +41,11 @@ namespace odb database_type& database (); + // Return the connection this transaction is on. + // + connection_type& + connection (); + // Return current transaction or throw if there is no transaction // in effect. // @@ -72,9 +78,10 @@ namespace odb friend class transaction; typedef odb::database database_type; + typedef odb::connection connection_type; - transaction_impl (database_type& db) - : database_ (db) + transaction_impl (database_type& db, connection_type& c) + : database_ (db), connection_ (c) { } @@ -93,8 +100,15 @@ namespace odb return database_; } + connection_type& + connection () + { + return connection_; + } + protected: database_type& database_; + connection_type& connection_; }; } |