diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-29 10:08:30 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-29 10:08:30 +0200 |
commit | a474f75b6bea51ecd5c3a870696dd575e25b0bc6 (patch) | |
tree | 8ac09f7f0c5d944fc7562c3fbb07ae9e0848066f /odb/lazy-ptr-impl.txx | |
parent | 1a0c6d83149149c36c228cb5515ea51feac24742 (diff) |
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.
Diffstat (limited to 'odb/lazy-ptr-impl.txx')
-rw-r--r-- | odb/lazy-ptr-impl.txx | 11 |
1 files changed, 10 insertions, 1 deletions
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<const T*> (p)); } + template <typename T, typename DB> + typename object_traits<T>::pointer_type lazy_ptr_base:: + loader (database_type& db, const typename object_traits<T>::id_type& id) + { + return static_cast<DB&> (db).template load<T> (id); + } + // // lazy_ptr_impl // @@ -35,9 +42,11 @@ namespace odb { typedef typename object_traits<T>::id_type id_type; typedef typename object_traits<T>::pointer_type pointer_type; + typedef pointer_type (*loader_type) (database_type&, const id_type&); + loader_type loader (reinterpret_cast<loader_type> (loader_)); const id_type& id (*static_cast<const id_type*> (id_)); - pointer_type p (db_->load<T> (id)); + pointer_type p (loader (*db_, id)); if (reset) reset_id (); |