aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/cache-traits.hxx15
-rw-r--r--odb/database.txx14
-rw-r--r--odb/no-op-cache-traits.hxx12
-rw-r--r--odb/polymorphic-object-result.txx4
-rw-r--r--odb/session.hxx6
-rw-r--r--odb/simple-object-result.txx5
6 files changed, 48 insertions, 8 deletions
diff --git a/odb/cache-traits.hxx b/odb/cache-traits.hxx
index 13363da..5732cfc 100644
--- a/odb/cache-traits.hxx
+++ b/odb/cache-traits.hxx
@@ -77,6 +77,13 @@ namespace odb
return position_type ();
}
+ static void
+ initialize (const position_type& p)
+ {
+ if (!p.empty_)
+ session_type::template initialize<object_type> (p.pos_);
+ }
+
static position_type
insert (odb::database& db, const pointer_type& p)
{
@@ -107,7 +114,7 @@ namespace odb
erase (const position_type& p)
{
if (!p.empty_)
- session_type::current ().template erase<object_type> (p.pos_);
+ session_type::template erase<object_type> (p.pos_);
}
};
@@ -154,6 +161,12 @@ namespace odb
pointer_type p (&obj);
return pointer_traits::insert (db, p);
}
+
+ static void
+ initialize (const position_type& p)
+ {
+ pointer_traits::initialize (p);
+ }
};
template <typename T, typename S>
diff --git a/odb/database.txx b/odb/database.txx
index df58f35..b5f9640 100644
--- a/odb/database.txx
+++ b/odb/database.txx
@@ -36,8 +36,11 @@ namespace odb
object_traits::persist (*this, obj);
- object_traits::reference_cache_traits::insert (
- *this, reference_cache_type<T>::convert (obj));
+ typename object_traits::reference_cache_traits::position_type p (
+ object_traits::reference_cache_traits::insert (
+ *this, reference_cache_type<T>::convert (obj)));
+
+ object_traits::reference_cache_traits::initialize (p);
return object_traits::id (obj);
}
@@ -58,8 +61,11 @@ namespace odb
// Get the canonical object pointer and insert it into object cache.
//
- object_traits::pointer_cache_traits::insert (
- *this, pointer_cache_type<pointer_type>::convert (pobj));
+ typename object_traits::pointer_cache_traits::position_type p (
+ object_traits::pointer_cache_traits::insert (
+ *this, pointer_cache_type<pointer_type>::convert (pobj)));
+
+ object_traits::pointer_cache_traits::initialize (p);
return object_traits::id (obj);
}
diff --git a/odb/no-op-cache-traits.hxx b/odb/no-op-cache-traits.hxx
index 1d9db7c..5600a81 100644
--- a/odb/no-op-cache-traits.hxx
+++ b/odb/no-op-cache-traits.hxx
@@ -128,6 +128,9 @@ namespace odb
static position_type
insert (odb::database&, void*) {return position_type ();}
+ static void
+ initialize (const position_type&) {}
+
static pointer_type
find (odb::database&, const id_type&) {return pointer_type ();}
@@ -151,6 +154,9 @@ namespace odb
//
static position_type
insert (odb::database&, void*) {return position_type ();}
+
+ static void
+ initialize (const position_type&) {}
};
// reference_cache_traits
@@ -188,6 +194,9 @@ namespace odb
static position_type
insert (odb::database&, object_type&) {return position_type ();}
+
+ static void
+ initialize (const position_type&) {}
};
template <typename T>
@@ -198,6 +207,9 @@ namespace odb
static position_type
insert (odb::database&, object_type&) {return position_type ();}
+
+ static void
+ initialize (const position_type&) {}
};
}
diff --git a/odb/polymorphic-object-result.txx b/odb/polymorphic-object-result.txx
index 5d6c479..69d365d 100644
--- a/odb/polymorphic-object-result.txx
+++ b/odb/polymorphic-object-result.txx
@@ -60,10 +60,12 @@ namespace odb
typedef odb::object_traits<object_type> object_traits;
- typename object_traits::reference_cache_traits::insert_guard ig (
+ typename object_traits::reference_cache_traits::position_type p (
object_traits::reference_cache_traits::insert (
res_->db_, res_->load_id (), obj));
+ typename object_traits::reference_cache_traits::insert_guard ig (p);
res_->load (&obj, false);
+ object_traits::reference_cache_traits::initialize (p);
ig.release ();
}
}
diff --git a/odb/session.hxx b/odb/session.hxx
index 472ea79..3f58a80 100644
--- a/odb/session.hxx
+++ b/odb/session.hxx
@@ -106,6 +106,10 @@ namespace odb
const typename object_traits<T>::pointer_type&);
template <typename T>
+ static void
+ initialize (const position<T>&) {}
+
+ template <typename T>
typename object_traits<T>::pointer_type
find (database_type&, const typename object_traits<T>::id_type&) const;
@@ -114,7 +118,7 @@ namespace odb
erase (database_type&, const typename object_traits<T>::id_type&);
template <typename T>
- void
+ static void
erase (const position<T>&);
diff --git a/odb/simple-object-result.txx b/odb/simple-object-result.txx
index 60705e8..f14caac 100644
--- a/odb/simple-object-result.txx
+++ b/odb/simple-object-result.txx
@@ -30,6 +30,7 @@ namespace odb
object_type& obj (pointer_traits::get_ref (p));
current (p);
load (obj, false);
+ object_traits::pointer_cache_traits::initialize (ig.position ());
ig.release ();
}
}
@@ -47,10 +48,12 @@ namespace odb
typedef odb::object_traits<object_type> object_traits;
- typename object_traits::reference_cache_traits::insert_guard ig (
+ typename object_traits::reference_cache_traits::position_type p (
object_traits::reference_cache_traits::insert (
res_->db_, res_->load_id (), obj));
+ typename object_traits::reference_cache_traits::insert_guard ig (p);
res_->load (obj, false);
+ object_traits::reference_cache_traits::initialize (p);
ig.release ();
}
}