From 6400b736456af65176c9c1959022f1eb49fcde32 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Jul 2010 11:02:07 +0200 Subject: Get rid of the session mechanism for now Add low-level API instead. --- odb/session.cxx | 120 -------------------------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 odb/session.cxx (limited to 'odb/session.cxx') diff --git a/odb/session.cxx b/odb/session.cxx deleted file mode 100644 index 9ee0104..0000000 --- a/odb/session.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// file : odb/session.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::make_pair - -#include -#include - -namespace odb -{ - session::type_map:: - ~type_map () - { - } - - session::object_proxy:: - ~object_proxy () - { - } - - // - // session - // - - static session* current_session = 0; - - session:: - session () - { - if (current_session != 0) - throw already_in_session (); - - current_session = this; - } - - bool session:: - has_current () - { - return current_session != 0; - } - - session& session:: - current () - { - if (current_session == 0) - throw not_in_session (); - - return *current_session; - } - - void session:: - current (session& s) - { - current_session = &s; - } - - void session:: - reset_current () - { - current_session = 0; - } - - void session:: - flush () - { - if (!transaction::has_current ()) - throw not_in_transaction (); - - // @@ Order of insertion and deletion can be important (triggers, - // id assignment, constraints etc). - // - - for (object_map::iterator i (object_map_.begin ()), - e (object_map_.end ()); i != e;) - { - object_proxy& pxy (*i->second); - - switch (pxy.state_) - { - case object_proxy::transient: - { - pxy.persist (); - - // If the id is auto-assigned, then we only get it now, so - // register with the id map. - // - if (pxy.id_source_ != ids_assigned) - pxy.register_id (id_map_, i); - - pxy.state_ = object_proxy::clean; - ++i; - break; - } - case object_proxy::dirty: - { - pxy.update (); - pxy.state_ = object_proxy::clean; - ++i; - break; - } - case object_proxy::erased: - { - pxy.erase (); - pxy.unregister_id (id_map_); - object_map_.erase (i++); - break; - } - case object_proxy::clean: - { - // Nothing to do for this case. - // - ++i; - break; - } - } - } - } -} -- cgit v1.1