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 
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 
00055         TableSchema(const TableSchema& ts, bool copyId = true);
00056 
00061         TableSchema(const TableSchema& ts, int setId);
00062 
00063         virtual ~TableSchema();
00064         
00067         virtual FieldList& insertField(uint index, Field *field);
00068 
00070         virtual void removeField(KexiDB::Field *field);
00071 
00076         IndexSchema* primaryKey() const { return m_pkey; }
00077 
00088         void setPrimaryKey(IndexSchema *pkey);
00089 
00090         const IndexSchema::ListIterator indicesIterator() const 
00091             { return IndexSchema::ListIterator(m_indices); }
00092 
00093         const IndexSchema::List* indices() { return &m_indices; }
00094 
00097         virtual void clear();
00098 
00102         QString debugString(bool includeTableName);
00103 
00105         virtual QString debugString();
00106 
00109         Connection* connection() const { return m_conn; }
00110 
00125         bool isKexiDBSystem() const { return m_isKexiDBSystem; }
00126 
00130         void setKexiDBSystem(bool set);
00131 
00134         virtual bool isNative() const { return m_native || m_isKexiDBSystem; }
00135         
00136         /* Sets native flag. Does not allow to set this off for system KexiDB table. */
00137         virtual void setNative(bool set);
00138 
00143         QuerySchema* query();
00144 
00147         Field* anyNonPKField();
00148 
00153         bool setLookupFieldSchema( const QString& fieldName, LookupFieldSchema *lookupFieldSchema );
00154 
00160         LookupFieldSchema *lookupFieldSchema( const Field& field ) const;
00161 
00163         LookupFieldSchema *lookupFieldSchema( const QString& fieldName );
00164 
00167         const QPtrVector<LookupFieldSchema>& lookupFieldsList();
00168 
00169     protected:
00171         TableSchema(Connection *conn, const QString & name = QString::null);
00172 
00173         IndexSchema::List m_indices;
00174 
00175         QGuardedPtr<Connection> m_conn;
00176         
00177         IndexSchema *m_pkey;
00178 
00179         QuerySchema *m_query; 
00180 
00181         class Private;
00182         Private *d;
00183 
00184     private:
00186         void init();
00187 
00189         void init(const TableSchema& ts, bool copyId);
00190 
00191         bool m_isKexiDBSystem : 1;
00192 
00193     friend class Connection;
00194 };
00195 
00200 class KEXI_DB_EXPORT InternalTableSchema : public TableSchema
00201 {
00202     public:
00203         InternalTableSchema(const QString& name);
00204         InternalTableSchema(const TableSchema& ts);
00205         virtual ~InternalTableSchema();
00206 };
00207 
00208 } //namespace KexiDB
00209 
00210 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys