]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EOEntity.h
added missing inline pathes
[sope] / sope-gdl1 / GDLAccess / EOEntity.h
1 /* 
2    EOEntity.h
3
4    Copyright (C) 1996 Free Software Foundation, Inc.
5
6    Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
7    Date: August 1996
8
9    This file is part of the GNUstep Database Library.
10
11    This library is free software; you can redistribute it and/or
12    modify it under the terms of the GNU Library General Public
13    License as published by the Free Software Foundation; either
14    version 2 of the License, or (at your option) any later version.
15
16    This library is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    Library General Public License for more details.
20
21    You should have received a copy of the GNU Library General Public
22    License along with this library; see the file COPYING.LIB.
23    If not, write to the Free Software Foundation,
24    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27 #ifndef __EOEntity_h__
28 #define __EOEntity_h__
29
30 #import <Foundation/NSString.h>
31
32 @class EOModel, EOAttribute, EORelationship;
33 @class EOSQLQualifier, EOExpressionArray;
34 @class NSMutableDictionary;
35
36 @interface EOEntity : NSObject
37 {
38     NSString            *name;
39     NSString            *className;
40     NSString            *externalName;
41     NSString            *externalQuery;
42     NSDictionary        *userDictionary;
43     NSArray             *primaryKeyAttributeNames; /* sorted array of names */
44     NSArray             *attributesNamesUsedForInsert;
45     NSArray             *classPropertyNames;
46
47     /* Garbage collectable objects */
48     EOModel             *model;                   /* non-retained */
49     EOSQLQualifier      *qualifier;
50     NSArray             *attributes;
51     NSMutableDictionary *attributesByName;
52     NSArray             *relationships;
53     NSMutableDictionary *relationshipsByName;     // name/EORelationship
54     NSArray             *primaryKeyAttributes;
55     NSArray             *classProperties;          // EOAttribute/EORelationship
56     NSArray             *attributesUsedForLocking;
57
58     /* Cached properties */
59     NSArray             *attributesUsedForInsert;  // cache from classProperties
60     NSArray             *attributesUsedForFetch;   // cache from classProperties
61     NSArray             *relationsUsedForFetch;    // cache from classProperties
62
63     struct {
64         BOOL isReadOnly:1;
65         BOOL createsMutableObjects:1;
66         BOOL isPropertiesCacheValid:1;
67     } flags;
68 }
69
70 /* Initializing instances */
71 - (id)initWithName:(NSString *)name;
72
73 /* Accessing the name */
74 - (NSString *)name;
75 - (BOOL)setName:(NSString *)name;
76 + (BOOL)isValidName:(NSString *)name;
77
78 /* Accessing the model */
79 - (void)setModel:(EOModel *)model;
80 - (EOModel *)model;
81 - (void)resetModel;
82 - (BOOL)hasModel;
83
84 /* Getting the qualifier */
85 - (EOSQLQualifier *)qualifier;
86
87 /* Accessing attributes */
88 - (BOOL)addAttribute:(EOAttribute *)attribute;
89 - (void)removeAttributeNamed:(NSString *)name;
90 - (EOAttribute *)attributeNamed:(NSString *)attributeName;
91 - (NSArray *)attributes;
92
93 /* Accessing relationships */
94 - (BOOL)addRelationship:(EORelationship *)relationship;
95 - (void)removeRelationshipNamed:(NSString *)name;
96 - (EORelationship *)relationshipNamed:(NSString *)relationshipName;
97 - (NSArray *)relationships;
98
99 /* Accessing primary key attributes */
100 - (BOOL)setPrimaryKeyAttributes:(NSArray *)keys;
101 - (NSArray *)primaryKeyAttributes;
102 - (NSArray *)primaryKeyAttributeNames;
103 - (BOOL)isValidPrimaryKeyAttribute:(EOAttribute *)anAttribute;
104
105 /* Getting primary keys and snapshot for row */
106 - (NSDictionary *)primaryKeyForRow:(NSDictionary *)row;
107 - (NSDictionary *)snapshotForRow:(NSDictionary *)aRow;
108
109 /* Getting attributes used for fetch/insert/update operations */
110 - (NSArray *)attributesUsedForInsert;
111 - (NSArray *)attributesUsedForFetch;
112 - (NSArray *)relationsUsedForFetch;
113 - (NSArray *)attributesNamesUsedForInsert;
114
115 /* Accessing class properties */
116 - (BOOL)setClassProperties:(NSArray *)properties;
117 - (NSArray *)classProperties;
118 - (NSArray *)classPropertyNames;
119 - (BOOL)isValidClassProperty:(id)aProp;
120 - (id)propertyNamed:(NSString *)name;
121 - (NSArray *)relationshipsNamed:(NSString *)_relationshipPath;
122
123 /* Accessing locking attributes */
124 - (BOOL)setAttributesUsedForLocking:(NSArray *)attributes;
125 - (NSArray *)attributesUsedForLocking;
126 - (BOOL)isValidAttributeUsedForLocking:(EOAttribute *)anAttribute;
127
128 /* Accessing the enterprise object class */
129 - (void)setClassName:(NSString *)name;
130 - (NSString *)className; 
131
132 /* Accessing external information */
133 - (void)setExternalName:(NSString *)name;
134 - (NSString *)externalName;
135
136 /* Accessing the external query */
137 - (void)setExternalQuery:(NSString *)query;
138 - (NSString *)externalQuery;
139
140 /* Accessing read-only status */
141 - (void)setReadOnly:(BOOL)flag;
142 - (BOOL)isReadOnly;
143
144 /* Accessing the user dictionary */
145 - (void)setUserDictionary:(NSDictionary *)dictionary;
146 - (NSDictionary *)userDictionary;
147
148 - (BOOL)referencesProperty:property;
149
150 @end
151
152
153 @interface EOEntity (EOEntityPrivate)
154
155 + (EOEntity *)entityFromPropertyList:(id)propertyList model:(EOModel *)model;
156 - (void)replaceStringsWithObjects;
157
158 - (id)propertyList;
159 - (void)setCreateMutableObjects:(BOOL)flag;
160 - (BOOL)createsMutableObjects;
161
162 - (void)validatePropertiesCache;
163 - (void)invalidatePropertiesCache;
164
165 @end
166
167 @interface EOEntity(ValuesConversion)
168
169 - (NSDictionary *)convertValuesToModel:(NSDictionary *)aRow;
170
171 @end /* EOAttribute (ValuesConversion) */
172
173 @class EOGlobalID, EOFetchSpecification;
174
175 @interface EOEntity(EOF2Additions)
176
177 - (BOOL)isAbstractEntity;
178
179 /* ids */
180
181 - (EOGlobalID *)globalIDForRow:(NSDictionary *)_row;
182 - (BOOL)isPrimaryKeyValidInObject:(id)_object;
183
184 /* refs to other models */
185
186 - (NSArray *)externalModelsReferenced;
187
188 /* fetch specs */
189
190 - (EOFetchSpecification *)fetchSpecificationNamed:(NSString *)_name;
191 - (NSArray *)fetchSpecificationNames;
192
193 /* names */
194
195 - (void)beautifyName;
196
197 @end
198
199 @class NSMutableDictionary;
200
201 @interface EOEntity(PropertyListCoding)
202
203 - (void)encodeIntoPropertyList:(NSMutableDictionary *)_plist;
204
205 @end
206
207 #import <EOControl/EOClassDescription.h>
208
209 @interface EOEntityClassDescription : EOClassDescription
210 {
211   EOEntity *entity;
212 }
213
214 - (id)initWithEntity:(EOEntity *)_entity;
215 - (EOEntity *)entity;
216
217 @end
218
219 #endif /* __EOEntity_h__ */