aboutsummaryrefslogtreecommitdiff
path: root/common/inheritance/polymorphism/test14.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-01 17:16:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-01 17:16:49 +0200
commit7b7a7b9a2a557535837c8d4b0b2af3e44b14594d (patch)
treea7644cffa9a8c902b404c81673b90b8b86bf402d /common/inheritance/polymorphism/test14.hxx
parente76ab3a1ac2487e0dcb16ecdfe0c6e53c3f1e86c (diff)
Handle inverse member in base class of polymorphic hierarchy
Diffstat (limited to 'common/inheritance/polymorphism/test14.hxx')
-rw-r--r--common/inheritance/polymorphism/test14.hxx100
1 files changed, 100 insertions, 0 deletions
diff --git a/common/inheritance/polymorphism/test14.hxx b/common/inheritance/polymorphism/test14.hxx
new file mode 100644
index 0000000..95baf61
--- /dev/null
+++ b/common/inheritance/polymorphism/test14.hxx
@@ -0,0 +1,100 @@
+// file : common/inheritance/polymorphism/test14.hxx
+// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST14_HXX
+#define TEST14_HXX
+
+#include <vector>
+
+#include <odb/core.hxx>
+
+// Test inverse pointer in polymorphic base.
+//
+#pragma db namespace table("t14_")
+namespace test14
+{
+ struct object1;
+ struct object2;
+ struct object3;
+ struct object4;
+
+ #pragma db object polymorphic session
+ struct base
+ {
+ virtual ~base ();
+
+ #pragma db id auto
+ unsigned long id;
+
+ object1* o1;
+ object2* o2;
+ std::vector<object3*> o3;
+ std::vector<object4*> o4;
+ };
+
+ #pragma db object
+ struct derived: base
+ {
+ unsigned long num;
+ };
+
+ // one-to-one(i)
+ //
+ #pragma db object session
+ struct object1
+ {
+ #pragma db id auto
+ unsigned long id;
+
+ #pragma db inverse(o1)
+ derived* d;
+ };
+
+ // one-to-many(i)
+ //
+ #pragma db object session
+ struct object2
+ {
+ #pragma db id auto
+ unsigned long id;
+
+ #pragma db inverse(o2)
+ std::vector<derived*> d;
+ };
+
+ // many-to-many(i)
+ //
+ #pragma db object session
+ struct object3
+ {
+ #pragma db id auto
+ unsigned long id;
+
+ #pragma db inverse(o3)
+ std::vector<derived*> d;
+ };
+
+ // many-to-one(i)
+ //
+ #pragma db object session
+ struct object4
+ {
+ #pragma db id auto
+ unsigned long id;
+
+ #pragma db inverse(o4)
+ derived* d;
+ };
+
+ inline base::
+ ~base ()
+ {
+ delete o1;
+ delete o2;
+ delete o3[0];
+ delete o4[0];
+ }
+}
+
+#endif // TEST14_HXX