From ab52a8c4e7f92358cabf1c81de3ddcc68c1b7090 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Aug 2013 15:16:09 +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/qt/containers/list-traits.hxx | 3 +++ odb/qt/containers/list-traits.txx | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'odb') diff --git a/odb/qt/containers/list-traits.hxx b/odb/qt/containers/list-traits.hxx index 17e7765..6541d3f 100644 --- a/odb/qt/containers/list-traits.hxx +++ b/odb/qt/containers/list-traits.hxx @@ -64,6 +64,9 @@ namespace odb c._start (); } + static bool + changed (const container_type&); + static void update (const container_type&, const functions&); diff --git a/odb/qt/containers/list-traits.txx b/odb/qt/containers/list-traits.txx index 2893236..8af5c85 100644 --- a/odb/qt/containers/list-traits.txx +++ b/odb/qt/containers/list-traits.txx @@ -5,6 +5,34 @@ namespace odb { template + bool access::container_traits >:: + changed (const container_type& c) + { + // Because modifications can cancel each other (e.g., push and pop), + // it is tricky to keep track of whether there are any changes in + // the container. Instead, we are just going to examine each element + // just like update(). + // + + // We should either be tracking or summarily changed. + // + if (c._tracking ()) + { + const vector_impl& impl (c._impl ()); + + for (std::size_t i (0), n (impl.size ()); i < n; ++i) + { + if (impl.state (i) != vector_impl::state_unchanged) + return true; + } + } + else + return true; + + return false; + } + + template void access::container_traits >:: update (const container_type& c, const functions& f) { -- cgit v1.1