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-2004 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 
00042 class KEXI_DB_EXPORT TableSchema : public FieldList, public SchemaData
00043 {
00044     public:
00045         typedef QPtrList<TableSchema> List; 
00046         typedef QPtrListIterator<TableSchema> ListIterator; 
00047 
00048         TableSchema(const QString & name);
00049         TableSchema(const SchemaData& sdata);
00050         TableSchema();
00051 
00053         TableSchema(const TableSchema& ts);
00054         
00055         virtual ~TableSchema();
00056         
00059         virtual FieldList& insertField(uint index, Field *field);
00060 
00062         virtual void removeField(KexiDB::Field *field);
00063 
00068         IndexSchema* primaryKey() const { return m_pkey; }
00069 
00080         void setPrimaryKey(IndexSchema *pkey);
00081 
00082         const IndexSchema::ListIterator indicesIterator() const 
00083             { return IndexSchema::ListIterator(m_indices); }
00084 
00085         const IndexSchema::List* indices() { return &m_indices; }
00086 
00089         virtual void clear();
00090 
00092         virtual QString debugString();
00093 
00096         Connection* connection() const { return m_conn; }
00097 
00112         bool isKexiDBSystem() const { return m_isKexiDBSystem; }
00113 
00117         void setKexiDBSystem(bool set);
00118 
00121         virtual bool isNative() const { return m_native || m_isKexiDBSystem; }
00122         
00123         /* Sets native flag. Does not allow to set this off for system KexiDB table. */
00124         virtual void setNative(bool set);
00125 
00130         QuerySchema* query();
00131 
00134         Field* anyNonPKField();
00135 
00136     protected:
00138         TableSchema(Connection *conn, const QString & name = QString::null);
00139 
00140         void init();
00141 
00142         IndexSchema::List m_indices;
00143 
00144         QGuardedPtr<Connection> m_conn;
00145         
00146         IndexSchema *m_pkey;
00147 
00148         QuerySchema *m_query; 
00149 
00150         class Private;
00151         Private *d;
00152 
00153     private:
00154         bool m_isKexiDBSystem : 1;
00155 
00156     friend class Connection;
00157 };
00158 
00163 class KEXI_DB_EXPORT InternalTableSchema : public TableSchema
00164 {
00165     public:
00166         InternalTableSchema(const QString& name);
00167         virtual ~InternalTableSchema();
00168 };
00169 
00170 } //namespace KexiDB
00171 
00172 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys