aboutsummaryrefslogtreecommitdiff
path: root/odb/tracer/database.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-21 16:27:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-21 16:27:34 +0200
commitbde4f5c3bddb437c5238bcb6dd2311bc57600ef1 (patch)
treee25658cc26cf40318847c60e8de01ac1720bd18a /odb/tracer/database.cxx
parent4c78c4b1e1a826a85468a4125813cec3dcbbbd06 (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/tracer/database.cxx')
-rw-r--r--odb/tracer/database.cxx25
1 files changed, 16 insertions, 9 deletions
diff --git a/odb/tracer/database.cxx b/odb/tracer/database.cxx
index 1359a26..90cfdfd 100644
--- a/odb/tracer/database.cxx
+++ b/odb/tracer/database.cxx
@@ -3,8 +3,8 @@
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
-#include <odb/transaction.hxx>
#include <odb/tracer/database.hxx>
+#include <odb/tracer/connection.hxx>
namespace odb
{
@@ -15,19 +15,26 @@ namespace odb
{
}
- unsigned long long database::
- execute (const char*, std::size_t)
+ transaction_impl* database::
+ begin ()
{
- return 0;
+ return connection ()->begin ();
}
- transaction_impl* database::
- begin ()
+ inline connection_ptr database::
+ connection ()
{
- if (odb::transaction::has_current ())
- throw already_in_transaction ();
+ // Go through the virtual connection_() function instead of
+ // directly to allow overriding.
+ //
+ return connection_ptr (
+ static_cast<tracer::connection*> (connection_ ()));
+ }
- return new transaction_impl (*this);
+ odb::connection* database::
+ connection_ ()
+ {
+ return new (details::shared) connection_type (*this);
}
}
}