aboutsummaryrefslogtreecommitdiff
path: root/common/inheritance/test.hxx
blob: e27ff7ae1cc5392d1dc06226e3b68074409befaf (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
// file      : common/inheritance/test.hxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license   : GNU GPL v2; see accompanying LICENSE file

#ifndef TEST_HXX
#define TEST_HXX

#include <string>
#include <vector>

#include <odb/core.hxx>

#pragma db value
struct comp
{
  unsigned int num;
  std::string str;

  std::vector<unsigned int> nums;

  bool
  operator== (const comp& y) const
  {
    return num == y.num && str == y.str && nums == y.nums;
  }
};

#pragma db object
struct base
{
  #pragma db id auto
  unsigned long id_;

  comp comp_;

  unsigned int num_;
  std::string str_;

  std::vector<std::string> strs_;

  bool
  operator== (const base& y) const
  {
    return
      id_ == y.id_ &&
      comp_ == y.comp_ &&
      num_ == y.num_ &&
      str_ == y.str_ &&
      strs_ == y.strs_;
  }
};

#pragma db object
struct object1: base
{
  unsigned int num1_;

  bool
  operator== (const object1& y) const
  {
    return static_cast<const base&> (*this) == y && num1_ == y.num1_;
  }
};

#pragma db object
struct object2: base
{
  #pragma db column ("derived_str")
  std::string str_;

  bool
  operator== (const object2& y) const
  {
    return static_cast<const base&> (*this) == y && str_ == y.str_;
  }
};

#pragma db object
struct reference
{
  #pragma db id auto
  unsigned long id_;

  object1* o1_;
};

#endif // TEST_HXX