kexi

tableschema.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
00003    Copyright (C) 2003-2006 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KEXIDB_TABLE_H
00022 #define KEXIDB_TABLE_H
00023 
00024 #include <qvaluelist.h>
00025 #include <qptrlist.h>
00026 #include <qstring.h>
00027 #include <qguardedptr.h>
00028 
00029 #include <kexidb/fieldlist.h>
00030 #include <kexidb/schemadata.h>
00031 #include <kexidb/indexschema.h>
00032 #include <kexidb/relationship.h>
00033 
00034 namespace KexiDB {
00035 
00036 class Connection;
00037 class LookupFieldSchema;
00038 
00043 class KEXI_DB_EXPORT TableSchema : public FieldList, public SchemaData
00044 {
00045     public:
00046         typedef QPtrList<TableSchema> List; 
00047         typedef QPtrListIterator<TableSchema> ListIterator; 
00048 
00049         TableSchema(const QString & name);
00050         TableSchema(const SchemaData& sdata);
00051         TableSchema();
00052 
00056         TableSchema(const TableSchema& ts, bool copyId = true);
00057         
00058         virtual ~TableSchema();
00059         
00062         virtual FieldList& insertField(uint index, Field *field);
00063 
00065         virtual void removeField(KexiDB::Field *field);
00066 
00071         IndexSchema* primaryKey() const { return m_pkey; }
00072 
00083         void setPrimaryKey(IndexSchema *pkey);
00084 
00085         const IndexSchema::ListIterator indicesIterator() const 
00086             { return IndexSchema::ListIterator(m_indices); }
00087 
00088         const IndexSchema::List* indices() { return &m_indices; }
00089 
00092         virtual void clear();
00093 
00097         QString debugString(bool includeTableName);
00098 
00100         virtual QString debugString();
00101 
00104         Connection* connection() const { return m_conn; }
00105 
00120         bool isKexiDBSystem() const { return m_isKexiDBSystem; }
00121 
00125         void setKexiDBSystem(bool set);
00126 
00129         virtual bool isNative() const { return m_native || m_isKexiDBSystem; }
00130         
00131         /* Sets native flag. Does not allow to set this off for system KexiDB table. */
00132         virtual void setNative(bool set);
00133 
00138         QuerySchema* query();
00139 
00142         Field* anyNonPKField();
00143 
00148         bool setLookupFieldSchema( const QString& fieldName, LookupFieldSchema *lookupFieldSchema );
00149 
00152         LookupFieldSchema *lookupFieldSchema( const Field& field ) const;
00153 
00155         LookupFieldSchema *lookupFieldSchema( const QString& fieldName );
00156 
00157     protected:
00159         TableSchema(Connection *conn, const QString & name = QString::null);
00160 
00161         void init();
00162 
00163         IndexSchema::List m_indices;
00164 
00165         QGuardedPtr<Connection> m_conn;
00166         
00167         IndexSchema *m_pkey;
00168 
00169         QuerySchema *m_query; 
00170 
00171         class Private;
00172         Private *d;
00173 
00174     private:
00175         bool m_isKexiDBSystem : 1;
00176 
00177     friend class Connection;
00178 };
00179 
00184 class KEXI_DB_EXPORT InternalTableSchema : public TableSchema
00185 {
00186     public:
00187         InternalTableSchema(const QString& name);
00188         virtual ~InternalTableSchema();
00189 };
00190 
00191 } //namespace KexiDB
00192 
00193 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys