From 539c92147e8d58c49f350c4070051a6ddf6b2354 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 20 Jan 2013 08:20:56 +0200 Subject: Add cache_ suffix to session cache functions This way they won't conflict with other functions (e.g., delayed database operations) that may have the same names. --- common/session/custom/session.hxx | 29 +++++++++++++++-------------- common/session/custom/session.txx | 21 +++++++++++---------- 2 files changed, 26 insertions(+), 24 deletions(-) (limited to 'common') diff --git a/common/session/custom/session.hxx b/common/session/custom/session.hxx index ce7e43c..b0a6694 100644 --- a/common/session/custom/session.hxx +++ b/common/session/custom/session.hxx @@ -96,13 +96,13 @@ private: // public: template - struct position + struct cache_position { typedef object_map map; typedef typename map::iterator iterator; - position (): map_ (0) {} - position (map& m, const iterator& p): map_ (&m), pos_ (p) {} + cache_position (): map_ (0) {} + cache_position (map& m, const iterator& p): map_ (&m), pos_ (p) {} map* map_; iterator pos_; @@ -111,18 +111,18 @@ public: // Cache management. // template - static position - insert (odb::database&, - const typename odb::object_traits::id_type&, - const typename odb::object_traits::pointer_type&); + static cache_position + _cache_insert (odb::database&, + const typename odb::object_traits::id_type&, + const typename odb::object_traits::pointer_type&); template static typename odb::object_traits::pointer_type - find (odb::database&, const typename odb::object_traits::id_type&); + _cache_find (odb::database&, const typename odb::object_traits::id_type&); template static void - erase (const position& p) + _cache_erase (const cache_position& p) { if (p.map_ != 0) p.map_->erase (p.pos_); @@ -132,22 +132,23 @@ public: // template static void - persist (const position& p) + _cache_persist (const cache_position& p) { - load (p); + _cache_load (p); } template static void - load (const position&); + _cache_load (const cache_position&); template static void - update (odb::database&, const T&); + _cache_update (odb::database&, const T&); template static void - erase (odb::database&, const typename odb::object_traits::id_type&); + _cache_erase (odb::database&, + const typename odb::object_traits::id_type&); private: // Post-commit/rollback callback. diff --git a/common/session/custom/session.txx b/common/session/custom/session.txx index 31c08c7..de1f3f0 100644 --- a/common/session/custom/session.txx +++ b/common/session/custom/session.txx @@ -5,15 +5,15 @@ #include template -typename session::position session:: -insert (odb::database&, - const typename odb::object_traits::id_type& id, - const typename odb::object_traits::pointer_type& obj) +typename session::cache_position session:: +_cache_insert (odb::database&, + const typename odb::object_traits::id_type& id, + const typename odb::object_traits::pointer_type& obj) { typedef odb::object_traits object_traits; if (current == 0) - return position (); // No session, return empty position. + return cache_position (); // No session, return empty position. std::shared_ptr& pm (current->map_[&typeid (T)]); @@ -29,12 +29,12 @@ insert (odb::database&, // assert (r.second); - return position (m, r.first); + return cache_position (m, r.first); } template typename odb::object_traits::pointer_type session:: -find (odb::database&, const typename odb::object_traits::id_type& id) +_cache_find (odb::database&, const typename odb::object_traits::id_type& id) { typedef typename odb::object_traits::pointer_type pointer_type; @@ -57,7 +57,7 @@ find (odb::database&, const typename odb::object_traits::id_type& id) template void session:: -load (const position& p) +_cache_load (const cache_position& p) { typedef typename odb::object_traits::pointer_type pointer_type; @@ -75,7 +75,7 @@ load (const position& p) template void session:: -update (odb::database&, const T& obj) +_cache_update (odb::database&, const T& obj) { typedef odb::object_traits object_traits; typedef typename object_traits::pointer_type pointer_type; @@ -105,7 +105,8 @@ update (odb::database&, const T& obj) template void session:: -erase (odb::database&, const typename odb::object_traits::id_type& id) +_cache_erase (odb::database&, + const typename odb::object_traits::id_type& id) { if (current == 0) return; // No session. -- cgit v1.1