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 
00058         IndexSchema(const IndexSchema& idx);
00059 
00065         virtual ~IndexSchema();
00066 
00070         virtual FieldList& addField(Field *field);
00071 
00073         TableSchema* table() const;
00074 
00079         Relationship::List* masterRelationships() { return &m_master_rels; }
00080 
00084         Relationship::List* detailsRelationships() { return &m_details_rels; }
00085 
00095         void attachRelationship(Relationship *rel);
00096 
00105         void detachRelationship(Relationship *rel);
00106 
00122         bool isAutoGenerated() const;
00123         
00126         bool isPrimaryKey() const;
00127         
00131         void setPrimaryKey(bool set);
00132 
00135         bool isUnique() const;
00136         
00141         void setUnique(bool set);
00142 
00144         virtual QString debugString();
00145     protected:
00146 
00154 //      IndexSchema(Field* singleField);
00155 
00159         void setAutoGenerated(bool set);
00160 
00166         void setForeignKey(bool set);
00167 
00170         void attachRelationship(Relationship *rel, bool ownedByMaster);
00171 
00172         TableSchema *m_tableSchema; 
00173 
00178         Relationship::List m_master_owned_rels; 
00179 
00181         Relationship::List m_master_rels; 
00182 
00184         Relationship::List m_details_rels; 
00185 
00186         bool m_primary : 1;
00187         bool m_unique : 1;
00188         bool m_isAutoGenerated : 1;
00189         bool m_isForeignKey : 1;
00190 
00191     friend class Connection;
00192     friend class TableSchema;
00193     friend class QuerySchema;
00194     friend class Relationship;
00195 };
00196 
00197 } //namespace KexiDB
00198 
00199 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys