Added a EditorSocial.
[UnsignedByte.git] / src / DAL / KeyDef.h
blobb483d7191aa47b3ebf1f416a4f955b50aafb2bfc
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 KeyDef.h
24 * This file contains the KeyDef class.
26 * @see KeyDef
27 */
29 #include "FieldDef.h"
30 #include "Types.h"
32 /**
33 * This class represents the definition of a key field in a table.
35 * Based on this class KeyImpl's will be generated.
36 */
37 class KeyDef : public FieldDef
39 public:
40 /** Constructs a key for the specified foreign table with the specified name. */
41 KeyDef(TableDefPtr foreignTable, cstring name, bool primary) : FieldDef(name, false, false), m_foreignTable(foreignTable), m_primary(primary) { Assert(foreignTable); }
43 /** Destructor, a noop. */
44 ~KeyDef() { }
47 /** Returns that this field is a key field. */
48 bool isKey() const { return true; }
50 /** Whether this field is a primary key field. */
51 bool isPrimaryKey() const { return m_primary; }
53 /** Returns the foreign table for this key, is NULL for native keys. */
54 TableDefPtr getForeignTable() { return m_foreignTable; }
56 private:
57 TableDefPtr m_foreignTable; /**< The foreign table for this key. */
58 bool m_primary; /**< Whether this key is a primary key. */