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