From 1896d36996ab48ed7271e855d7e32b4e61f64896 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Apr 2012 16:48:00 +0200 Subject: Polymorphic inheritance support --- odb/simple-object-result.txx | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 odb/simple-object-result.txx (limited to 'odb/simple-object-result.txx') diff --git a/odb/simple-object-result.txx b/odb/simple-object-result.txx new file mode 100644 index 0000000..832ff7f --- /dev/null +++ b/odb/simple-object-result.txx @@ -0,0 +1,65 @@ +// file : odb/simple-object-result.txx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +namespace odb +{ + // + // object_result_impl + // + + template + object_result_impl:: + ~object_result_impl () + { + } + + template + void object_result_impl:: + load () + { + // First check the session. + // + const id_type& id (load_id ()); + + pointer_type p ( + object_traits::pointer_cache_traits::find (database (), 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 (database (), id, p)); + + object_type& obj (pointer_traits::get_ref (p)); + current (p); + load (obj, false); + ig.release (); + } + } + + // + // object_result_iterator + // + + template + void object_result_iterator:: + load (object_type& obj) + { + if (res_->end ()) + return; + + typedef odb::object_traits object_traits; + + typename object_traits::reference_cache_traits::insert_guard ig ( + object_traits::reference_cache_traits::insert ( + res_->database (), res_->load_id (), obj)); + res_->load (obj, false); + ig.release (); + } +} -- cgit v1.1