From 5b6649e6f7dd256147b48197a007c23001cef647 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 21 Aug 2011 16:27:34 +0200 Subject: 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. --- odb/transaction.hxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'odb/transaction.hxx') 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_; }; } -- cgit v1.1