aboutsummaryrefslogtreecommitdiff
path: root/odb/polymorphic-map.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/polymorphic-map.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/polymorphic-map.hxx')
-rw-r--r--odb/polymorphic-map.hxx34
1 files changed, 33 insertions, 1 deletions
diff --git a/odb/polymorphic-map.hxx b/odb/polymorphic-map.hxx
index 5c3e434..3c0883f 100644
--- a/odb/polymorphic-map.hxx
+++ b/odb/polymorphic-map.hxx
@@ -149,7 +149,8 @@ namespace odb
};
template <typename T, database_id DB>
- bool dispatch_impl (
+ bool
+ dispatch_impl (
typename polymorphic_concrete_info<
typename object_traits<T>::root_type>::call_type c,
database& db,
@@ -235,6 +236,37 @@ namespace odb
return r;
}
+
+ template <typename T, database_id DB, typename ST>
+ void
+ section_load_impl (odb::connection& conn,
+ typename object_traits<T>::root_type& obj,
+ bool top)
+ {
+ typedef object_traits_impl<T, DB> derived_traits;
+ typedef typename derived_traits::statements_type statements_type;
+ typedef typename statements_type::connection_type connection_type;
+
+ connection_type& c (static_cast<connection_type&> (conn));
+ statements_type& sts (c.statement_cache ().template find_object<T> ());
+
+ ST::load (sts.extra_statement_cache (), static_cast<T&> (obj), top);
+ }
+
+ template <typename T, database_id DB, typename ST>
+ void
+ section_update_impl (odb::connection& conn,
+ const typename object_traits<T>::root_type& obj)
+ {
+ typedef object_traits_impl<T, DB> derived_traits;
+ typedef typename derived_traits::statements_type statements_type;
+ typedef typename statements_type::connection_type connection_type;
+
+ connection_type& c (static_cast<connection_type&> (conn));
+ statements_type& sts (c.statement_cache ().template find_object<T> ());
+
+ ST::update (sts.extra_statement_cache (), static_cast<const T&> (obj));
+ }
}
#include <odb/polymorphic-map.ixx>