From 658a2f07b47ed80bd3ca35edd7380493c326daa3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 27 Oct 2011 15:16:49 +0200 Subject: Add support for persistent classes without object ids New pragma id (object). New test: common/no-id. --- odb/object-result.txx | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'odb/object-result.txx') diff --git a/odb/object-result.txx b/odb/object-result.txx index c19e482..843ec59 100644 --- a/odb/object-result.txx +++ b/odb/object-result.txx @@ -9,18 +9,18 @@ namespace odb { // - // result_impl + // object_result_impl // template - result_impl:: - ~result_impl () + object_result_impl:: + ~object_result_impl () { } template - typename result_impl::pointer_type& - result_impl:: + typename object_result_impl::pointer_type& + object_result_impl:: current () { if (pointer_traits::null_ptr (current_) && !end_) @@ -62,11 +62,38 @@ namespace odb } // - // result_iterator + // object_result_impl_no_id // + template + object_result_impl_no_id:: + ~object_result_impl_no_id () + { + } template - void result_iterator:: + typename object_result_impl_no_id::pointer_type& + object_result_impl_no_id:: + current () + { + if (pointer_traits::null_ptr (current_) && !end_) + { + // Objects without ids are not stored in session cache. + // + pointer_type p (object_traits::create ()); + object_type& obj (pointer_traits::get_ref (p)); + current (p); + load (obj); + } + + return current_; + } + + // + // object_result_iterator + // + + template + void object_result_iterator:: load (object_type& obj) { if (res_->end ()) -- cgit v1.1