blob: 95baf616f16970b266e39320bc83519d27c39472 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
|