diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-05 15:50:07 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-05 15:50:07 +0200 |
commit | 1b88d6afa7839d087e5fc252195c5c4f60475e9f (patch) | |
tree | df7e216f369295e15211f5dbb92979bff8aef731 | |
parent | ddd2dd88c8b52d33a9306066c626f4405179b921 (diff) |
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.
-rw-r--r-- | odb/boost/multi-index/container-traits.hxx | 26 | ||||
-rw-r--r-- | odb/boost/unordered/container-traits.hxx | 52 |
2 files changed, 42 insertions, 36 deletions
diff --git a/odb/boost/multi-index/container-traits.hxx b/odb/boost/multi-index/container-traits.hxx index 5f5616a..c0dbba4 100644 --- a/odb/boost/multi-index/container-traits.hxx +++ b/odb/boost/multi-index/container-traits.hxx @@ -85,7 +85,8 @@ namespace odb class multi_index_traits { public: - static container_kind const kind = ck_ordered; + static const container_kind kind = ck_ordered; + static const bool smart = false; typedef ::boost::multi_index_container<V, ISP, A> container_type; typedef typename container_type::template nth_index<N>::type @@ -104,7 +105,7 @@ namespace odb index_type i (0); for (typename ordered_container_type::const_iterator j (oc.begin ()), e (oc.end ()); j != e; ++j) - f.insert_one (i++, *j); + f.insert (i++, *j); } static void @@ -117,7 +118,7 @@ namespace odb { index_type dummy; value_type v; - more = f.load_all (dummy, v); + more = f.select (dummy, v); #ifdef ODB_CXX11 oc.push_back (std::move (v)); #else @@ -129,19 +130,19 @@ namespace odb static void update (const container_type& c, const functions& f) { - f.delete_all (); + f.delete_ (); const ordered_container_type& oc (c.template get<N> ()); index_type i (0); for (typename ordered_container_type::const_iterator j (oc.begin ()), e (oc.end ()); j != e; ++j) - f.insert_one (i++, *j); + f.insert (i++, *j); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; @@ -151,7 +152,8 @@ namespace odb class multi_index_traits<V, ISP, A, -1> { public: - static container_kind const kind = ck_set; + static const container_kind kind = ck_set; + static const bool smart = false; typedef ::boost::multi_index_container<V, ISP, A> container_type; typedef V value_type; @@ -164,7 +166,7 @@ namespace odb { for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (*i); + f.insert (*i); } static void @@ -175,7 +177,7 @@ namespace odb while (more) { value_type v; - more = f.load_all (v); + more = f.select (v); #ifdef ODB_CXX11 c.insert (std::move (v)); #else @@ -187,17 +189,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); + f.insert (*i); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; diff --git a/odb/boost/unordered/container-traits.hxx b/odb/boost/unordered/container-traits.hxx index 49011eb..369027f 100644 --- a/odb/boost/unordered/container-traits.hxx +++ b/odb/boost/unordered/container-traits.hxx @@ -29,7 +29,8 @@ namespace odb class access::container_traits< ::boost::unordered_set<V, H, P, A> > { public: - static container_kind const kind = ck_set; + static const container_kind kind = ck_set; + static const bool smart = false; typedef ::boost::unordered_set<V, H, P, A> container_type; typedef V value_type; @@ -42,7 +43,7 @@ namespace odb { for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (*i); + f.insert (*i); } static void @@ -53,7 +54,7 @@ namespace odb while (more) { value_type v; - more = f.load_all (v); + more = f.select (v); #ifdef ODB_CXX11 c.insert (std::move (v)); #else @@ -65,17 +66,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); + f.insert (*i); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; @@ -89,7 +90,8 @@ namespace odb class access::container_traits< ::boost::unordered_multiset<V, H, P, A> > { public: - static container_kind const kind = ck_multiset; + static const container_kind kind = ck_multiset; + static const bool smart = false; typedef ::boost::unordered_multiset<V, H, P, A> container_type; typedef V value_type; @@ -102,7 +104,7 @@ namespace odb { for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (*i); + f.insert (*i); } static void @@ -113,7 +115,7 @@ namespace odb while (more) { value_type v; - more = f.load_all (v); + more = f.select (v); #ifdef ODB_CXX11 c.insert (std::move (v)); #else @@ -125,17 +127,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); + f.insert (*i); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; @@ -145,7 +147,8 @@ namespace odb class access::container_traits< ::boost::unordered_map<K, V, H, P, A> > { public: - static container_kind const kind = ck_map; + static const container_kind kind = ck_map; + static const bool smart = false; typedef ::boost::unordered_map<K, V, H, P, A> container_type; @@ -161,7 +164,7 @@ namespace odb { for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (i->first, i->second); + f.insert (i->first, i->second); } static void @@ -173,7 +176,7 @@ namespace odb { key_type k; value_type v; - more = f.load_all (k, v); + more = f.select (k, v); #ifdef ODB_CXX11 c.insert (pair_type (std::move (k), std::move (v))); @@ -186,17 +189,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->first, i->second); + f.insert (i->first, i->second); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; @@ -210,7 +213,8 @@ namespace odb class access::container_traits< ::boost::unordered_multimap<K, V, H, P, A> > { public: - static container_kind const kind = ck_multimap; + static const container_kind kind = ck_multimap; + static const bool smart = false; typedef ::boost::unordered_multimap<K, V, H, P, A> container_type; @@ -226,7 +230,7 @@ namespace odb { for (typename container_type::const_iterator i (c.begin ()), e (c.end ()); i != e; ++i) - f.insert_one (i->first, i->second); + f.insert (i->first, i->second); } static void @@ -238,7 +242,7 @@ namespace odb { key_type k; value_type v; - more = f.load_all (k, v); + more = f.select (k, v); #ifdef ODB_CXX11 c.insert (pair_type (std::move (k), std::move (v))); @@ -251,17 +255,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->first, i->second); + f.insert (i->first, i->second); } static void erase (const functions& f) { - f.delete_all (); + f.delete_ (); } }; } |