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/database.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/database.hxx')
-rw-r--r-- | odb/database.hxx | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/odb/database.hxx b/odb/database.hxx index bc7a10b..c4458d9 100644 --- a/odb/database.hxx +++ b/odb/database.hxx @@ -15,6 +15,7 @@ #include <odb/forward.hxx> #include <odb/query.hxx> #include <odb/result.hxx> +#include <odb/connection.hxx> #include <odb/exceptions.hxx> #include <odb/details/export.hxx> @@ -152,19 +153,31 @@ namespace odb unsigned long long execute (const std::string& statement); - virtual unsigned long long - execute (const char* statement, std::size_t length) = 0; + unsigned long long + execute (const char* statement, std::size_t length); + + // Transactions. + // + public: + transaction_impl* + begin (); - // Transaction API. + // Connections. // public: - virtual transaction_impl* - begin () = 0; + connection_ptr + connection (); protected: database (); protected: + typedef odb::connection connection_type; + + virtual connection_type* + connection_ () = 0; + + protected: template <typename T> typename object_traits<T>::id_type persist_ (const typename object_traits<T>::pointer_type&); |