Added 'length' to area.
[UnsignedByte.git] / src / DAL / Relation.h
blob845b4ece16103434d6ea8a1b6d5b73b451140b67
1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #pragma once
22 /**
23 * @file Relation.h
24 * @brief This file contains the Relation class.
26 * @see Relation
27 */
29 #include "Types.h"
31 /**
32 * This class may be used to easily create a new relation.
34 * Using this class a new entry in a relational table is made.
35 * This entry connects two rows in the different tables the relational table refers to.
36 * Keys may be added throug the <code>addKey</code> function.
37 * Fields within the relational table may be set with the <code>addField</code> method.
38 * When the relation is fully specified the entry may be added with the <code>save</code> method.
39 * Note: <code>save</code> may only be called once!
41 * @see addKey
42 * @see addField
43 * @see save
44 */
45 class Relation
47 public:
48 /** Construct a new Relation object for the specified table. */
49 Relation(TableImplPtr table);
51 /** Destructor, a noop. */
52 ~Relation();
55 /** Returns the relational table this Relation belongs to. */
56 TableImplPtr getTable() { return m_table; }
59 /** Add a key from the specified field with the specified value. */
60 void addKey(KeyImplPtr key, value_type value);
62 /** Add a value from the specified field with the specified value. */
63 void addField(FieldImplPtr field, value_type value);
65 /** Add a value from the specified field with the specified value. */
66 void addField(FieldImplPtr field, cstring value);
69 /** Save the Relation to the database. */
70 void save();
72 private:
73 TableImplPtr m_table; /**< The table this relation belongs to. */
74 KeysPtr m_keys; /**< The keys that were added to this relation. */
75 SavableManagerPtr m_manager; /**< The savable manager that will be used to save the relation. */