kexi

tableschema.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
3 Copyright (C) 2003-2006 Jaroslaw Staniek <js@iidea.pl>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KEXIDB_TABLE_H
22#define KEXIDB_TABLE_H
23
24#include <tqvaluelist.h>
25#include <tqptrlist.h>
26#include <tqstring.h>
27#include <tqguardedptr.h>
28
29#include <kexidb/fieldlist.h>
30#include <kexidb/schemadata.h>
31#include <kexidb/indexschema.h>
32#include <kexidb/relationship.h>
33
34namespace KexiDB {
35
36class Connection;
37class LookupFieldSchema;
38
42class KEXI_DB_EXPORT TableSchema : public FieldList, public SchemaData
43{
44 public:
45 typedef TQPtrList<TableSchema> List;
46 typedef TQPtrListIterator<TableSchema> ListIterator;
47
48 TableSchema(const TQString & name);
49 TableSchema(const SchemaData& sdata);
51
55 TableSchema(const TableSchema& ts, bool copyId = true);
56
61 TableSchema(const TableSchema& ts, int setId);
62
63 virtual ~TableSchema();
64
67 virtual FieldList& insertField(uint index, Field *field);
68
70 virtual void removeField(KexiDB::Field *field);
71
76 IndexSchema* primaryKey() const { return m_pkey; }
77
88 void setPrimaryKey(IndexSchema *pkey);
89
90 const IndexSchema::ListIterator indicesIterator() const
91 { return IndexSchema::ListIterator(m_indices); }
92
93 const IndexSchema::List* indices() { return &m_indices; }
94
97 virtual void clear();
98
102 TQString debugString(bool includeTableName);
103
105 virtual TQString debugString();
106
109 Connection* connection() const { return m_conn; }
110
125 bool isKexiDBSystem() const { return m_isKexiDBSystem; }
126
130 void setKexiDBSystem(bool set);
131
134 virtual bool isNative() const { return m_native || m_isKexiDBSystem; }
135
136 /* Sets native flag. Does not allow to set this off for system KexiDB table. */
137 virtual void setNative(bool set);
138
143 QuerySchema* query();
144
147 Field* anyNonPKField();
148
153 bool setLookupFieldSchema( const TQString& fieldName, LookupFieldSchema *lookupFieldSchema );
154
160 LookupFieldSchema *lookupFieldSchema( const Field& field ) const;
161
163 LookupFieldSchema *lookupFieldSchema( const TQString& fieldName );
164
167 const TQPtrVector<LookupFieldSchema>& lookupFieldsList();
168
169 protected:
171 TableSchema(Connection *conn, const TQString & name = TQString());
172
173 IndexSchema::List m_indices;
174
175 TQGuardedPtr<Connection> m_conn;
176
177 IndexSchema *m_pkey;
178
180
181 class Private;
182 Private *d;
183
184 private:
186 void init();
187
189 void init(const TableSchema& ts, bool copyId);
190
191 bool m_isKexiDBSystem : 1;
192
193 friend class Connection;
194};
195
200class KEXI_DB_EXPORT InternalTableSchema : public TableSchema
201{
202 public:
203 InternalTableSchema(const TQString& name);
205 virtual ~InternalTableSchema();
206};
207
208} //namespace KexiDB
209
210#endif
Provides database connection, allowing queries and data modification.
Definition connection.h:62
Meta-data for a field.
Definition field.h:73
Provides information about database index that can be created for a database table.
Definition indexschema.h:44
Provides information about lookup field's setup.
KexiDB::QuerySchema provides information about database query.
Connection * connection() const
IndexSchema * primaryKey() const
Definition tableschema.h:76
virtual bool isNative() const
QuerySchema * m_query
cached query schema that is defined by "select * from <this_table_name>"
TQPtrListIterator< TableSchema > ListIterator
Iterator for tables list.
Definition tableschema.h:46
TQPtrList< TableSchema > List
Type of tables list.
Definition tableschema.h:45
bool isKexiDBSystem() const
High-level database connectivity library with database backend drivers.