aboutsummaryrefslogtreecommitdiff
path: root/odb/traits.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-05-06 12:05:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-08-14 15:18:23 +0200
commit91830e3bd38a05c73d03a5dfb88997799d44274b (patch)
tree399f1fc61ce959ac63b8b7ebaf5e3c58f80d8a7d /odb/traits.hxx
parent72b262ee4f375089256f6438152bd323df1ff5a3 (diff)
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.
Diffstat (limited to 'odb/traits.hxx')
-rw-r--r--odb/traits.hxx48
1 files changed, 48 insertions, 0 deletions
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<section> {};
+
template <typename T, database_id DB>
//
// 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<T, DB>
{
};
+
+ //
+ // Get root image from a polymorphic image chain.
+ //
+
+ template <typename T, std::size_t d>
+ struct root_image_impl
+ {
+ typedef root_image_impl<typename T::base_traits, d - 1> 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 <typename T>
+ struct root_image_impl<T, 1>
+ {
+ typedef typename T::image_type image_type;
+
+ static image_type&
+ get (image_type& i) {return i;}
+ };
+
+ template <typename T, bool p>
+ struct root_image
+ {
+ typedef root_image_impl<T, T::depth> 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 <typename T>
+ struct root_image<T, false>
+ {
+ typedef typename T::image_type image_type;
+
+ static image_type&
+ get (image_type& i) {return i;}
+ };
}
#include <odb/post.hxx>