diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-03-10 11:07:43 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-03-21 15:40:00 +0200 |
commit | c31fc72be48b037fff1cc2b46a812d20d4b601c4 (patch) | |
tree | 574161b9c1db69b88ca1e439e2ca8a44f405dc27 /odb/relational/context.cxx | |
parent | a98ab50a31b57d609588ad13c39e8819c3cd0f9e (diff) |
Cache current context in static variable
Diffstat (limited to 'odb/relational/context.cxx')
-rw-r--r-- | odb/relational/context.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/odb/relational/context.cxx b/odb/relational/context.cxx index e7a4f21..f763b8d 100644 --- a/odb/relational/context.cxx +++ b/odb/relational/context.cxx @@ -3,12 +3,23 @@ // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v3; see accompanying LICENSE file +#include <cassert> + #include <odb/relational/context.hxx> using namespace std; namespace relational { + context* context::current_; + + context:: + ~context () + { + if (current_ == this) + current_ = 0; + } + context:: context () : data_ (current ().data_) @@ -19,6 +30,8 @@ namespace relational context (data* d) : data_ (d) { + assert (current_ == 0); + current_ = this; } bool context:: |