aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/transaction.cxx
blob: 6690d92e829c76c68274b74e8be53c38e682df89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// file      : odb/sqlite/transaction.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license   : GNU GPL v2; see accompanying LICENSE file

#include <odb/sqlite/transaction.hxx>

namespace odb
{
  namespace sqlite
  {
    transaction& transaction::
    current ()
    {
      // While the impl type can be of the concrete type, the transaction
      // object can be created as either odb:: or odb::sqlite:: 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);
    }
  }
}