kexi

relationship.h
1/* This file is part of the KDE project
2 Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef KEXIDB_RELATIONSHIP_H
21#define KEXIDB_RELATIONSHIP_H
22
23#include <kexidb/field.h>
24
25namespace KexiDB {
26
73class IndexSchema;
74class TableSchema;
75class QuerySchema;
76
77class KEXI_DB_EXPORT Relationship
78{
79 public:
80 typedef TQPtrList<Relationship> List;
81 typedef TQPtrListIterator<Relationship> ListIterator;
82
86 Relationship();
87
91 Relationship(IndexSchema* masterIndex, IndexSchema* detailsIndex);
92
93 virtual ~Relationship();
94
97 IndexSchema* masterIndex() const { return m_masterIndex; }
98
101 IndexSchema* detailsIndex() const { return m_detailsIndex; }
102
106 Field::PairList* fieldPairs() { return &m_pairs; }
107
108 bool isEmpty() const { return m_pairs.isEmpty(); }
109
112 TableSchema* masterTable() const;
113
116 TableSchema* detailsTable() const;
117
129 void setIndices(IndexSchema* masterIndex, IndexSchema* detailsIndex);
130
131 protected:
132 Relationship( QuerySchema *query, Field *field1, Field *field2 );
133
134 void createIndices( QuerySchema *query, Field *field1, Field *field2 );
135
138 void setIndices(IndexSchema* masterIndex, IndexSchema* detailsIndex, bool ownedByMaster);
139
140 IndexSchema *m_masterIndex;
141 IndexSchema *m_detailsIndex;
142
143 Field::PairList m_pairs;
144
145 bool m_masterIndexOwned : 1;
146 bool m_detailsIndexOwned : 1;
147
148 friend class Connection;
149 friend class TableSchema;
150 friend class QuerySchema;
151 friend class IndexSchema;
152};
153
154} //namespace KexiDB
155
156#endif
High-level database connectivity library with database backend drivers.