diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-24 17:03:38 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-24 17:03:38 +0300 |
commit | 0f1f6841ce5a50d5b315c24d796a2d8e2627d136 (patch) | |
tree | e16bbf9e23ca75a88b8af032c4e3ed299ca8db66 /libodb/odb/simple-object-result.txx | |
parent | 823026b58211a4166de06ac243d978dcb9930271 (diff) | |
parent | 26e36b3a9d7b49d46ecfa69b447482251acba8ac (diff) |
Merge branch 'libodb' into multi-package
Diffstat (limited to 'libodb/odb/simple-object-result.txx')
-rw-r--r-- | libodb/odb/simple-object-result.txx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/libodb/odb/simple-object-result.txx b/libodb/odb/simple-object-result.txx new file mode 100644 index 0000000..00521f8 --- /dev/null +++ b/libodb/odb/simple-object-result.txx @@ -0,0 +1,58 @@ +// file : odb/simple-object-result.txx +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + // + // object_result_impl + // + + template <typename T> + void object_result_impl<T>:: + load () + { + // First check the session. + // + const id_type& id (load_id ()); + + pointer_type p (object_traits::pointer_cache_traits::find (db_, id)); + + if (!pointer_traits::null_ptr (p)) + current (p, false); // Pointer from cache should not be guarded. + else + { + p = object_traits::create (); + + typename object_traits::pointer_cache_traits::insert_guard ig ( + object_traits::pointer_cache_traits::insert (db_, id, p)); + + object_type& obj (pointer_traits::get_ref (p)); + current (p); + load (obj, false); + object_traits::pointer_cache_traits::load (ig.position ()); + ig.release (); + } + } + + // + // object_result_iterator + // + + template <typename T, typename ID> + void object_result_iterator<T, ID, false>:: + load (object_type& obj) + { + if (res_->end ()) + return; + + typedef odb::object_traits<object_type> object_traits; + + 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::load (p); + ig.release (); + } +} |