aboutsummaryrefslogtreecommitdiff
path: root/common/session/custom/session.cxx
blob: b50493f852aea73f6f1dcad285de6e68c5272243 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// file      : common/session/custom/session.cxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
// license   : GNU GPL v2; see accompanying LICENSE file

#include <cassert>

#include "session.hxx"

static session* current_; // Use TLS in multi-threaded applications.

session::
session ()
{
  assert (current_ == 0);
  current_ = this;
}

session::
~session ()
{
  assert (current_ == this);
  current_ = 0;
}

bool session::
has_current ()
{
  return current_ != 0;
}

session& session::
current ()
{
  assert (current_ != 0);
  return *current_;
}

void session::
flush (odb::database& db)
{
  for (type_map::iterator i (map_.begin ()), e (map_.end ()); i != e; ++i)
    i->second->flush (db);
}

void session::
mark ()
{
  for (type_map::iterator i (map_.begin ()), e (map_.end ()); i != e; ++i)
    i->second->mark ();
}