1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
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. *
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. *
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 ***************************************************************************/
24 * @brief This file contains the Relation class.
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!
48 /** Construct a new Relation object for the specified table. */
49 Relation(TableImplPtr table
);
51 /** Destructor, a noop. */
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. */
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. */