kexi

indexschema.h
1/* This file is part of the KDE project
2 Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KEXIDB_INDEX_H
21#define KEXIDB_INDEX_H
22
23#include <tqvaluelist.h>
24#include <tqstring.h>
25
26#include <kexidb/fieldlist.h>
27#include <kexidb/schemadata.h>
28#include <kexidb/relationship.h>
29
30namespace KexiDB {
31
32class Connection;
33class TableSchema;
34class QuerySchema;
35class Relationship;
36
43class KEXI_DB_EXPORT IndexSchema : public FieldList, public SchemaData
44{
45 public:
46 typedef TQPtrList<IndexSchema> List;
47 typedef TQPtrListIterator<IndexSchema> ListIterator;
48
55 IndexSchema(TableSchema *tableSchema);
56
68 IndexSchema(const IndexSchema& idx, TableSchema& parentTable);
69
75 virtual ~IndexSchema();
76
80 virtual FieldList& addField(Field *field);
81
83 TableSchema* table() const;
84
89 Relationship::List* masterRelationships() { return &m_master_rels; }
90
94 Relationship::List* detailsRelationships() { return &m_details_rels; }
95
105 void attachRelationship(Relationship *rel);
106
115 void detachRelationship(Relationship *rel);
116
132 bool isAutoGenerated() const;
133
136 bool isPrimaryKey() const;
137
141 void setPrimaryKey(bool set);
142
145 bool isUnique() const;
146
151 void setUnique(bool set);
152
154 virtual TQString debugString();
155 protected:
156
164// IndexSchema(Field* singleField);
165
169 void setAutoGenerated(bool set);
170
176 void setForeignKey(bool set);
177
180 void attachRelationship(Relationship *rel, bool ownedByMaster);
181
182 TableSchema *m_tableSchema;
183
187
188 Relationship::List m_master_owned_rels;
189
191 Relationship::List m_master_rels;
192
194 Relationship::List m_details_rels;
195
196 bool m_primary : 1;
197 bool m_unique : 1;
198 bool m_isAutoGenerated : 1;
199 bool m_isForeignKey : 1;
200
201 friend class Connection;
202 friend class TableSchema;
203 friend class QuerySchema;
204 friend class Relationship;
205};
206
207} //namespace KexiDB
208
209#endif
Provides database connection, allowing queries and data modification.
Definition connection.h:62
FieldList(bool owner=false)
Definition fieldlist.cpp:29
Field * field(uint id)
Definition fieldlist.h:76
Meta-data for a field.
Definition field.h:73
Relationship::List m_master_rels
TableSchema * table() const
Relationship::List m_master_owned_rels
table on that index is built
Relationship::List * detailsRelationships()
Definition indexschema.h:94
Relationship::List m_details_rels
Relationship::List * masterRelationships()
Definition indexschema.h:89
IndexSchema(TableSchema *tableSchema)
virtual FieldList & addField(Field *field)
KexiDB::QuerySchema provides information about database query.
High-level database connectivity library with database backend drivers.