aboutsummaryrefslogtreecommitdiff
path: root/qt/common/containers/change-tracking/test.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-05 15:50:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-05 15:50:08 +0200
commit43fa55c1b8e389838c83be933bb30a2caaf7468d (patch)
tree310bc0ecc43ea38276a7e8ff2a541f2cba395333 /qt/common/containers/change-tracking/test.hxx
parent3eee63801cbe833f6557d6f85c5778b6209140be (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.
Diffstat (limited to 'qt/common/containers/change-tracking/test.hxx')
-rw-r--r--qt/common/containers/change-tracking/test.hxx43
1 files changed, 43 insertions, 0 deletions
diff --git a/qt/common/containers/change-tracking/test.hxx b/qt/common/containers/change-tracking/test.hxx
new file mode 100644
index 0000000..7ad230e
--- /dev/null
+++ b/qt/common/containers/change-tracking/test.hxx
@@ -0,0 +1,43 @@
+// file : qt/common/containers/change-tracking/test.hxx
+// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST_HXX
+#define TEST_HXX
+
+#include <common/config.hxx> // HAVE_CXX11
+
+#include <memory>
+
+#ifdef HAVE_CXX11
+# include <utility> // std::move
+#endif
+
+#include <QtCore/QString>
+
+#include <odb/core.hxx>
+#include <odb/qt/list.hxx>
+
+#pragma db object pointer(std::auto_ptr)
+struct object
+{
+ object () {}
+ object (const QString& id): id_ (id) {}
+
+#ifdef HAVE_CXX11
+ object (const object& x): id_ (x.id_), i (x.i), s (x.s) {}
+ object (object&& x): id_ (std::move (x.id_)), i (x.i), s (std::move (x.s)) {}
+#endif
+
+ #pragma db id
+ QString id_;
+
+ unsigned int i;
+
+ QOdbList<QString> s;
+
+ inline bool
+ operator== (const object& o) {return id_ == o.id_ && i == o.i && s == o.s;}
+};
+
+#endif // TEST_HXX