aboutsummaryrefslogtreecommitdiff
path: root/odb/tracer/transaction.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:36:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:36:21 +0200
commiteef022894e7d6f1f371da432722a733b98fd8709 (patch)
tree23c42ae76accab7708b73efc98b210b87bc9b1ab /odb/tracer/transaction.cxx
parent0b5578e85153c43374f022a0454bbb41288da52c (diff)
Initial implementation
Diffstat (limited to 'odb/tracer/transaction.cxx')
-rw-r--r--odb/tracer/transaction.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/odb/tracer/transaction.cxx b/odb/tracer/transaction.cxx
new file mode 100644
index 0000000..46309de
--- /dev/null
+++ b/odb/tracer/transaction.cxx
@@ -0,0 +1,26 @@
+// file : odb/tracer/transaction.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#include <odb/tracer/transaction.hxx>
+
+namespace odb
+{
+ namespace tracer
+ {
+ transaction& transaction::
+ current ()
+ {
+ // While the impl type can be of the concrete type, the transaction
+ // object can be created as either odb:: or odb::tracer:: type. To
+ // work around that we are going to hard-cast one two the other
+ // relying on the fact that they have the same representation and
+ // no virtual functions. The former is checked in the tests.
+ //
+ odb::transaction& b (odb::transaction::current ());
+ dynamic_cast<transaction_impl&> (b.implementation ());
+ return reinterpret_cast<transaction&> (b);
+ }
+ }
+}