From 91830e3bd38a05c73d03a5dfb88997799d44274b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 6 May 2013 12:05:39 +0200 Subject: Add support for object sections Sections are an optimization mechanism that allows the partitioning of data members of a persistent class into groups that can be separately loaded and/or updated. --- odb/traits.hxx | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'odb/traits.hxx') diff --git a/odb/traits.hxx b/odb/traits.hxx index 0fd11e4..495d972 100644 --- a/odb/traits.hxx +++ b/odb/traits.hxx @@ -181,6 +181,12 @@ namespace odb struct id_type {}; }; + // Specialization for section to allow instantiation of all the load() + // signature. + // + template <> + struct object_traits
{}; + template // // If a C++ compiler issues an error pointing to this struct and @@ -271,6 +277,48 @@ namespace odb struct composite_value_traits: access::composite_value_traits { }; + + // + // Get root image from a polymorphic image chain. + // + + template + struct root_image_impl + { + typedef root_image_impl base_type; + typedef typename base_type::image_type image_type; + + static image_type& + get (typename T::image_type& i) {return base_type::get (*i.base);} + }; + + template + struct root_image_impl + { + typedef typename T::image_type image_type; + + static image_type& + get (image_type& i) {return i;} + }; + + template + struct root_image + { + typedef root_image_impl impl_type; + typedef typename impl_type::image_type image_type; + + static image_type& + get (typename T::image_type& i) {return impl_type::get (i);} + }; + + template + struct root_image + { + typedef typename T::image_type image_type; + + static image_type& + get (image_type& i) {return i;} + }; } #include -- cgit v1.1