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/database.hxx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'odb/database.hxx') 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 #include #include +#include #include #include @@ -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 object_traits::id_type persist_ (const typename object_traits::pointer_type&); -- cgit v1.1