blob: 2c02d093216d2f035f47b2d21b55de99daa6d46e (
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
|
// file : evolution/drop-table/model.hxx
// license : GNU GPL v2; see accompanying LICENSE file
#ifndef MODEL_VERSION
# error model.hxx included directly
#endif
#include <vector>
#include <string>
#include <odb/core.hxx>
#pragma db model version(1, MODEL_VERSION)
#define MODEL_NAMESPACE_IMPL(V) v##V
#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V)
namespace MODEL_NAMESPACE(MODEL_VERSION)
{
#pragma db object
struct object
{
object (unsigned long id = 0): id_ (id) {}
#pragma db id
unsigned long id_;
std::string str;
};
#pragma db object
struct object1
{
object1 (): o (0) {}
~object1 () {delete o;}
#pragma db id auto
unsigned long id_;
object* o;
std::vector<int> nums;
};
#if MODEL_VERSION == 3
#pragma db object(object1) deleted(3)
#endif
// Make sure we also clean up base tables when dropping a
// table corresponding to the polymorphic derived object.
//
#pragma db value
struct value
{
value (unsigned long n = 0, const std::string& s = ""): num (n), str (s) {}
unsigned long num;
std::string str;
};
#pragma db object polymorphic
struct root
{
root (unsigned long n = 0, const std::string& s = ""): id (n, s) {}
virtual ~root () {}
#pragma db id
value id;
};
#pragma db object
struct base: root
{
base (unsigned long n = 0, const std::string& s = "")
: root (n, s), num (n) {}
unsigned long num;
};
#pragma db object
struct derived: base
{
derived (unsigned long n = 0, const std::string& s = "")
: base (n, s), str (s) {}
std::string str;
};
#if MODEL_VERSION == 3
#pragma db object(derived) deleted(3)
#endif
}
#undef MODEL_NAMESPACE
#undef MODEL_NAMESPACE_IMPL
|