From b366c3176462d470e445bc8aeb93a13df87e0518 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Jan 2013 12:51:22 +0200 Subject: Cleanup object cache position type --- odb/cache-traits.hxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'odb/cache-traits.hxx') diff --git a/odb/cache-traits.hxx b/odb/cache-traits.hxx index c0c1272..6a6741e 100644 --- a/odb/cache-traits.hxx +++ b/odb/cache-traits.hxx @@ -27,7 +27,17 @@ namespace odb typedef odb::pointer_traits pointer_traits; typedef typename pointer_traits::element_type object_type; typedef typename object_traits::id_type id_type; - typedef session::object_position position_type; + + struct position_type + { + typedef session::position base_type; + + position_type (): empty_ (true) {} + position_type (const base_type& pos): empty_ (false), pos_ (pos) {} + + bool empty_; + base_type pos_; + }; struct insert_guard { @@ -35,13 +45,13 @@ namespace odb insert_guard (const position_type& pos): pos_ (pos) {} ~insert_guard () {erase (pos_);} - position_type + const position_type& position () const {return pos_;} void - release () {pos_.map_ = 0;} + release () {pos_.empty_ = true;} - // Note: doesn't call erase() on the old position (assumes not set). + // Note: doesn't call erase() on the old position (assumes empty). // void reset (const position_type& pos) {pos_ = pos;} @@ -94,8 +104,8 @@ namespace odb static void erase (const position_type& p) { - if (p.map_ != 0) - session::current ().erase (p); + if (!p.empty_) + session::current ().erase (p.pos_); } }; -- cgit v1.1