From e93dcc2ecabee46d31aedf9f4ddc8058956c78ad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 5 Feb 2013 15:50:07 +0200 Subject: Add support for change-tracking containers ODB now supports "smart" ordered containers. Such containers get extra functions for updating and deleting individual elements. Based on this functionality implement two change-tracking containers: odb::vector (equivalent to std::vector) and QOdbList (equivalent to QList). New tests: common/container/change-tracking and qt/common/container/change- tracking. --- odb/qt/containers/qhash-traits.hxx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'odb/qt/containers/qhash-traits.hxx') diff --git a/odb/qt/containers/qhash-traits.hxx b/odb/qt/containers/qhash-traits.hxx index 57b072e..b44bc51 100644 --- a/odb/qt/containers/qhash-traits.hxx +++ b/odb/qt/containers/qhash-traits.hxx @@ -18,7 +18,8 @@ namespace odb class access::container_traits > { public: - static container_kind const kind = ck_map; + static const container_kind kind = ck_map; + static const bool smart = false; typedef QHash container_type; typedef Key key_type; @@ -32,7 +33,7 @@ namespace odb { for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (i.key (), i.value ()); + f.insert (i.key (), i.value ()); } static void @@ -44,7 +45,7 @@ namespace odb { key_type k; value_type v; - more = f.load_all (k, v); + more = f.select (k, v); c.insert (k, v); // @@ Use std::move in C++11. } } @@ -52,17 +53,17 @@ namespace odb static void update (const container_type& c, const functions& f) { - f.delete_all (); + f.delete_ (); for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (i.key (), i.value ()); + f.insert (i.key (), i.value ()); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; @@ -74,7 +75,8 @@ namespace odb class access::container_traits > { public: - static container_kind const kind = ck_multimap; + static const container_kind kind = ck_multimap; + static const bool smart = false; typedef QMultiHash container_type; typedef Key key_type; @@ -88,7 +90,7 @@ namespace odb { for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (i.key (), i.value ()); + f.insert (i.key (), i.value ()); } static void @@ -100,7 +102,7 @@ namespace odb { key_type k; value_type v; - more = f.load_all (k, v); + more = f.select (k, v); c.insert (k, v); //@@ Use std::move in C++11. } } @@ -108,17 +110,17 @@ namespace odb static void update (const container_type& c, const functions& f) { - f.delete_all (); + f.delete_ (); for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (i.key (), i.value ()); + f.insert (i.key (), i.value ()); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; } -- cgit v1.1