aboutsummaryrefslogtreecommitdiff
path: root/odb/semantics/relational/key.hxx
blob: f714876829f2d45763f198f30833d4406cc4d24f (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      : odb/semantics/relational/key.hxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license   : GNU GPL v3; see accompanying LICENSE file

#ifndef ODB_SEMANTICS_RELATIONAL_KEY_HXX
#define ODB_SEMANTICS_RELATIONAL_KEY_HXX

#include <odb/semantics/relational/elements.hxx>

namespace semantics
{
  namespace relational
  {
    class key;
    class column;

    class contains: public edge
    {
    public:
      typedef relational::key key_type;
      typedef relational::column column_type;

      key_type&
      key () const
      {
        return *key_;
      }

      column_type&
      column () const
      {
        return *column_;
      }

    public:
      void
      set_left_node (key_type& n)
      {
        key_ = &n;
      }

      void
      set_right_node (column_type& n)
      {
        column_ = &n;
      }

    protected:
      key_type* key_;
      column_type* column_;
    };

    class key: public virtual node
    {
      typedef std::vector<contains*> contains_list;

    public:
      typedef
      pointer_iterator<contains_list::const_iterator>
      contains_iterator;

      contains_iterator
      contains_begin () const
      {
        return contains_.begin ();
      }

      contains_iterator
      contains_end () const
      {
        return contains_.end ();
      }

      contains_list::size_type
      contains_size () const
      {
        return contains_.size ();
      }

    public:
      void
      add_edge_left (contains& e)
      {
        contains_.push_back (&e);
      }

    private:
      contains_list contains_;
    };
  }
}

#endif // ODB_SEMANTICS_RELATIONAL_KEY_HXX