From a474f75b6bea51ecd5c3a870696dd575e25b0bc6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Oct 2012 10:08:30 +0200 Subject: Add static multi-database support for lazy pointers A lazy pointer must load the object using the static database interface with which it was initialized. --- odb/lazy-ptr-impl.hxx | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'odb/lazy-ptr-impl.hxx') diff --git a/odb/lazy-ptr-impl.hxx b/odb/lazy-ptr-impl.hxx index 257cef8..db4d5d6 100644 --- a/odb/lazy-ptr-impl.hxx +++ b/odb/lazy-ptr-impl.hxx @@ -21,6 +21,7 @@ namespace odb { void* id_; database* db_; + void* loader_; void (*free_) (void*); void* (*copy_) (const void*); }; @@ -57,11 +58,6 @@ namespace odb void reset (); - // Reset the id and set the database to the new value. - // - void - reset (database_type&); - // Reset the id. // void @@ -88,7 +84,10 @@ namespace odb // Makes a copy of id. // void - reset_ (database_type*, const void* id, free_func, copy_func); + reset_ (database_type*, + void* loader, + const void* id, + free_func, copy_func); template static void @@ -98,9 +97,14 @@ namespace odb static void* copy (const void*); + template + static typename object_traits::pointer_type + loader (database_type&, const typename object_traits::id_type&); + protected: void* id_; database_type* db_; + void* loader_; private: free_func free_; @@ -113,8 +117,8 @@ namespace odb public: lazy_ptr_impl (); - template - lazy_ptr_impl (database_type&, const ID&); + template + lazy_ptr_impl (DB&, const ID&); lazy_ptr_impl (const lazy_ptr_impl&); @@ -154,9 +158,15 @@ namespace odb using lazy_ptr_base::reset; using lazy_ptr_base::reset_id; - template + template + void + reset (DB&, const ID&); + + // Reset the id and set the database to the new value. + // + template void - reset (database_type&, const ID&); + reset_db (DB&); template void -- cgit v1.1