kexi

indexschema.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KEXIDB_INDEX_H
00021 #define KEXIDB_INDEX_H
00022 
00023 #include <qvaluelist.h>
00024 #include <qstring.h>
00025 
00026 #include <kexidb/fieldlist.h>
00027 #include <kexidb/schemadata.h>
00028 #include <kexidb/relationship.h>
00029 
00030 namespace KexiDB {
00031 
00032 class Connection;
00033 class TableSchema;
00034 class QuerySchema;
00035 class Relationship;
00036 
00043 class KEXI_DB_EXPORT IndexSchema : public FieldList, public SchemaData
00044 {
00045     public:
00046         typedef QPtrList<IndexSchema> List;
00047         typedef QPtrListIterator<IndexSchema> ListIterator;
00048 
00055         IndexSchema(TableSchema *tableSchema);
00056 
00068         IndexSchema(const IndexSchema& idx, TableSchema& parentTable);
00069 
00075         virtual ~IndexSchema();
00076 
00080         virtual FieldList& addField(Field *field);
00081 
00083         TableSchema* table() const;
00084 
00089         Relationship::List* masterRelationships() { return &m_master_rels; }
00090 
00094         Relationship::List* detailsRelationships() { return &m_details_rels; }
00095 
00105         void attachRelationship(Relationship *rel);
00106 
00115         void detachRelationship(Relationship *rel);
00116 
00132         bool isAutoGenerated() const;
00133         
00136         bool isPrimaryKey() const;
00137         
00141         void setPrimaryKey(bool set);
00142 
00145         bool isUnique() const;
00146         
00151         void setUnique(bool set);
00152 
00154         virtual QString debugString();
00155     protected:
00156 
00164 //      IndexSchema(Field* singleField);
00165 
00169         void setAutoGenerated(bool set);
00170 
00176         void setForeignKey(bool set);
00177 
00180         void attachRelationship(Relationship *rel, bool ownedByMaster);
00181 
00182         TableSchema *m_tableSchema; 
00183 
00188         Relationship::List m_master_owned_rels; 
00189 
00191         Relationship::List m_master_rels; 
00192 
00194         Relationship::List m_details_rels; 
00195 
00196         bool m_primary : 1;
00197         bool m_unique : 1;
00198         bool m_isAutoGenerated : 1;
00199         bool m_isForeignKey : 1;
00200 
00201     friend class Connection;
00202     friend class TableSchema;
00203     friend class QuerySchema;
00204     friend class Relationship;
00205 };
00206 
00207 } //namespace KexiDB
00208 
00209 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys