// file : odb/object-result.txx // author : Boris Kolpackov // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include #include namespace odb { // // result_impl // template result_impl:: ~result_impl () { } template typename result_impl::pointer_type& result_impl:: current () { if (pointer_traits::null_ptr (current_) && !end_) { if (!session::has_current ()) { pointer_type p (object_traits::create ()); object_type& obj (pointer_traits::get_ref (p)); current (p); load (obj); } else { // First check the session. // const id_type& id (load_id ()); pointer_type p ( pointer_cache_traits::find (database (), id)); if (!pointer_traits::null_ptr (p)) current (p); else { pointer_type p (object_traits::create ()); typename pointer_cache_traits::insert_guard ig ( pointer_cache_traits::insert (database (), id, p)); object_type& obj (pointer_traits::get_ref (p)); current (p); load (obj); ig.release (); } } } return current_; } // // result_iterator // template void result_iterator:: load (object_type& obj) { if (res_->end ()) return; if (!session::has_current ()) res_->load (obj); else { typename reference_cache_traits::insert_guard ig ( reference_cache_traits::insert ( res_->database (), res_->load_id (), obj)); res_->load (obj); ig.release (); } } }