aboutsummaryrefslogtreecommitdiff
path: root/common/view/olv/test9.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-02-08 12:08:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-02-08 12:08:55 +0200
commit10be61ad26034a574a013c979549aaedf9aa8382 (patch)
treea4a0d5385a1a54776a5cafabc4d2f603a1e8a452 /common/view/olv/test9.hxx
parentedb7ba7437aa577d65da942aaf778c16c9a501ed (diff)
Split view/olv test into multiple headers files
VC++ complains that the object file is too large.
Diffstat (limited to 'common/view/olv/test9.hxx')
-rw-r--r--common/view/olv/test9.hxx79
1 files changed, 79 insertions, 0 deletions
diff --git a/common/view/olv/test9.hxx b/common/view/olv/test9.hxx
new file mode 100644
index 0000000..18c6c32
--- /dev/null
+++ b/common/view/olv/test9.hxx
@@ -0,0 +1,79 @@
+// file : common/view/olv/test9.hxx
+// copyright : Copyright (c) 2009-2015 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST9_HXX
+#define TEST9_HXX
+
+#include <string>
+#include <memory> // shared_ptr
+
+#include <odb/core.hxx>
+
+// Test loading polymorphic objects.
+//
+#pragma db namespace table("t9_") session
+namespace test9
+{
+ using std::shared_ptr;
+
+ #pragma db object polymorphic pointer(shared_ptr)
+ struct root
+ {
+ virtual ~root () {}
+ root (int n_ = 0): n (n_) {}
+
+ #pragma db id auto
+ int id;
+
+ int n;
+ };
+
+ #pragma db object
+ struct base: root
+ {
+ base (int n_ = 0, const char* s_ = ""): root (n_), s (s_) {}
+
+ std::string s;
+ };
+
+ #pragma db object
+ struct derived: base
+ {
+ derived (int n_ = 0, const char* s_ = "", bool b_ = false)
+ : base (n_, s_), b (b_) {}
+
+ bool b;
+ };
+
+ // Load via root.
+ //
+ #pragma db view object(root)
+ struct view1r
+ {
+ shared_ptr<root> o;
+ int n;
+ };
+
+ // Load via base.
+ //
+ #pragma db view object(base)
+ struct view1b
+ {
+ std::string s;
+ shared_ptr<base> o;
+ int n;
+ };
+
+ // Load via derived.
+ //
+ #pragma db view object(derived)
+ struct view1d
+ {
+ std::string s;
+ shared_ptr<derived> o;
+ int n;
+ };
+}
+
+#endif // TEST9_HXX