Nebula
Loading...
Searching...
No Matches
relation.h
Go to the documentation of this file.
1#pragma once
2#ifndef DB_RELATION_H
3#define DB_RELATION_H
4//------------------------------------------------------------------------------
15#include "core/refcounted.h"
16#include "db/table.h"
17
18//------------------------------------------------------------------------------
19namespace Db
20{
22{
24public:
26 Relation();
28 virtual ~Relation();
30 void SetParent(const Ptr<Table>& table, const Attr::AttrId& columnId);
32 const Ptr<Table>& GetParentTable() const;
34 const Attr::AttrId& GetParentColumnId() const;
36 void SetChild(const Ptr<Table>& table, const Attr::AttrId& columnId);
38 const Ptr<Table>& GetChildTable() const;
40 const Attr::AttrId& GetChildColumnId() const;
41
42private:
47};
48
49//------------------------------------------------------------------------------
52inline void
53Relation::SetParent(const Ptr<Table>& table, const Attr::AttrId& columnId)
54{
55 n_assert(0 != table);
56 this->parentTable = table;
57 this->parentColumnId = columnId;
58}
59
60//------------------------------------------------------------------------------
63inline const Ptr<Table>&
65{
66 return this->parentTable;
67}
68
69//------------------------------------------------------------------------------
72inline const Attr::AttrId&
74{
75 return this->parentColumnId;
76}
77
78//------------------------------------------------------------------------------
81inline void
82Relation::SetChild(const Ptr<Table>& table, const Attr::AttrId& columnId)
83{
84 n_assert(0 != table);
85 this->childTable = table;
86 this->childColumnId = columnId;
87}
88
89//------------------------------------------------------------------------------
92inline const Ptr<Table>&
94{
95 return this->childTable;
96}
97
98//------------------------------------------------------------------------------
101inline const Attr::AttrId&
103{
104 return this->childColumnId;
105}
106
107} // namespace Db
108//------------------------------------------------------------------------------
109#endif
An attribute ID is used to carry attribute types (no values) around.
Definition attrid.h:20
The common base class of Nebula.
Definition refcounted.h:38
A Relation object describes a relation between 2 tables which are linked through a common attribute.
Definition relation.h:22
Ptr< Table > parentTable
Definition relation.h:43
const Attr::AttrId & GetChildColumnId() const
get child column id
Definition relation.h:102
Relation()
constructor
Definition relation.cc:16
Attr::AttrId parentColumnId
Definition relation.h:44
__DeclareClass(Relation)
const Ptr< Table > & GetChildTable() const
get child table
Definition relation.h:93
void SetChild(const Ptr< Table > &table, const Attr::AttrId &columnId)
set child table and column id
Definition relation.h:82
Ptr< Table > childTable
Definition relation.h:45
Attr::AttrId childColumnId
Definition relation.h:46
virtual ~Relation()
destructor
Definition relation.cc:24
void SetParent(const Ptr< Table > &table, const Attr::AttrId &columnId)
set the parent table and column id
Definition relation.h:53
const Ptr< Table > & GetParentTable() const
get parent table
Definition relation.h:64
const Attr::AttrId & GetParentColumnId() const
get parent column id
Definition relation.h:73
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
#define n_assert(exp)
Definition debug.h:50
Definition column.cc:10