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 KeyDef class.
34 * This class represents the definition of a key field in a table.
36 * Based on this class KeyImpl's will be generated.
38 class KeyDef
: public FieldDef
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. */
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
; }
58 TableDefPtr m_foreignTable
; /**< The foreign table for this key. */
59 bool m_primary
; /**< Whether this key is a primary key. */