relationship.h
Go to the documentation of this file.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_RELATIONSHIP_H 00021 #define KEXIDB_RELATIONSHIP_H 00022 00023 #include <kexidb/field.h> 00024 00025 namespace KexiDB { 00026 00073 class IndexSchema; 00074 class TableSchema; 00075 class QuerySchema; 00076 00077 class KEXI_DB_EXPORT Relationship 00078 { 00079 public: 00080 typedef QPtrList<Relationship> List; 00081 typedef QPtrListIterator<Relationship> ListIterator; 00082 00086 Relationship(); 00087 00091 Relationship(IndexSchema* masterIndex, IndexSchema* detailsIndex); 00092 00093 virtual ~Relationship(); 00094 00097 IndexSchema* masterIndex() const { return m_masterIndex; } 00098 00101 IndexSchema* detailsIndex() const { return m_detailsIndex; } 00102 00106 Field::PairList* fieldPairs() { return &m_pairs; } 00107 00108 bool isEmpty() const { return m_pairs.isEmpty(); } 00109 00112 TableSchema* masterTable() const; 00113 00116 TableSchema* detailsTable() const; 00117 00129 void setIndices(IndexSchema* masterIndex, IndexSchema* detailsIndex); 00130 00131 protected: 00132 Relationship( QuerySchema *query, Field *field1, Field *field2 ); 00133 00134 void createIndices( QuerySchema *query, Field *field1, Field *field2 ); 00135 00138 void setIndices(IndexSchema* masterIndex, IndexSchema* detailsIndex, bool ownedByMaster); 00139 00140 IndexSchema *m_masterIndex; 00141 IndexSchema *m_detailsIndex; 00142 00143 Field::PairList m_pairs; 00144 00145 bool m_masterIndexOwned : 1; 00146 bool m_detailsIndexOwned : 1; 00147 00148 friend class Connection; 00149 friend class TableSchema; 00150 friend class QuerySchema; 00151 friend class IndexSchema; 00152 }; 00153 00154 } //namespace KexiDB 00155 00156 #endif
