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.txx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'odb/lazy-ptr-impl.txx') diff --git a/odb/lazy-ptr-impl.txx b/odb/lazy-ptr-impl.txx index 91d51d9..c14f349 100644 --- a/odb/lazy-ptr-impl.txx +++ b/odb/lazy-ptr-impl.txx @@ -24,6 +24,13 @@ namespace odb return new T (*static_cast (p)); } + template + typename object_traits::pointer_type lazy_ptr_base:: + loader (database_type& db, const typename object_traits::id_type& id) + { + return static_cast (db).template load (id); + } + // // lazy_ptr_impl // @@ -35,9 +42,11 @@ namespace odb { typedef typename object_traits::id_type id_type; typedef typename object_traits::pointer_type pointer_type; + typedef pointer_type (*loader_type) (database_type&, const id_type&); + loader_type loader (reinterpret_cast (loader_)); const id_type& id (*static_cast (id_)); - pointer_type p (db_->load (id)); + pointer_type p (loader (*db_, id)); if (reset) reset_id (); -- cgit v1.1