]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EORelationship.h
renamed PostgreSQL72 to PostgreSQL, install in Library/GDLAdaptors-1.1
[sope] / sope-gdl1 / GDLAccess / EORelationship.h
1 /* 
2    EORelationship.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 __EORelationship_h__
28 #define __EORelationship_h__
29
30 #import <Foundation/NSString.h>
31 #import <GDLAccess/EOJoinTypes.h>
32
33 @class NSString, NSDictionary, NSException;
34 @class EOModel, EOEntity, EOAttribute;
35
36 @interface EORelationship : NSObject
37 {
38     NSString     *name;
39     NSString     *definition;
40     NSDictionary *userDictionary;
41
42     /* Garbage collectable objects */
43     EOEntity     *entity; /* non-retained */
44     EOEntity     *destinationEntity; /* non-retained */
45
46     /* Computed values */
47     NSMutableArray *componentRelationships;
48
49     struct {
50         BOOL    isFlattened:1;
51         BOOL    isToMany:1;
52         BOOL    createsMutableObjects:1;
53         BOOL    isMandatory:1;
54     } flags;
55
56     // EOJoin
57
58     EOAttribute *sourceAttribute;
59     EOAttribute *destinationAttribute;
60 }
61
62 /* Initializing instances */
63 - (id)initWithName:(NSString*)name;
64
65 /* Accessing the name */
66 - (BOOL)setName:(NSString*)name;
67 - (NSString*)name;
68 + (BOOL)isValidName:(NSString*)name;
69
70 /* Using joins */
71
72 - (NSArray*)joins;
73
74 /* Convering source row in destination row */
75 - (NSDictionary*)foreignKeyForRow:(NSDictionary*)row;
76
77 /* Accessing the definition */
78 - (NSArray*)componentRelationships;
79 - (void)setDefinition:(NSString*)definition;
80 - (NSString*)definition;
81
82 /* Accessing the entities joined */
83 - (void)setEntity:(EOEntity*)entity;
84 - (EOEntity*)entity;
85 - (void)resetEntities;
86 - (BOOL)hasEntity;
87 - (BOOL)hasDestinationEntity;
88 - (EOEntity*)destinationEntity;
89
90 /* Checking type */
91 - (BOOL)isCompound;  // always NO (no compound joins supported)
92 - (BOOL)isFlattened;
93
94 /* Accessing to-many property */
95 - (BOOL)setToMany:(BOOL)flag;
96 - (BOOL)isToMany;
97
98 /* Checking references */
99 - (BOOL)referencesProperty:(id)property;
100
101 /* Accessing the user dictionary */
102 - (void)setUserDictionary:(NSDictionary*)dictionary;
103 - (NSDictionary*)userDictionary;
104
105 @end
106
107 @interface EORelationship(EOJoin)
108
109 - (void)loadJoinPropertyList:(id)propertyList;
110
111 /* Accessing join properties */
112 - (void)setDestinationAttribute:(EOAttribute*)attribute;
113 - (EOAttribute*)destinationAttribute;
114 - (void)setSourceAttribute:(EOAttribute*)attribute;
115 - (EOAttribute*)sourceAttribute;
116 - (EORelationship*)relationship;
117
118 @end
119
120 @interface EORelationship (EORelationshipPrivate)
121
122 + (EORelationship*)relationshipFromPropertyList:(id)propertyList
123   model:(EOModel*)model;
124 - (void)replaceStringsWithObjects;
125 - (void)initFlattenedRelationship;
126
127 - (id)propertyList;
128
129 - (void)setCreateMutableObjects:(BOOL)flag;
130 - (BOOL)createsMutableObjects;
131
132 @end /* EORelationship (EORelationshipPrivate) */
133
134 @class NSMutableDictionary;
135
136 @interface EORelationship(PropertyListCoding)
137
138 - (void)encodeIntoPropertyList:(NSMutableDictionary *)_plist;
139
140 @end
141
142 @class NSException;
143
144 @interface EORelationship(EOF2Additions)
145
146 /* constraints */
147
148 - (void)setIsMandatory:(BOOL)_flag;
149 - (BOOL)isMandatory;
150
151 - (NSException *)validateValue:(id *)_value;
152
153 @end
154
155 #endif /* __EORelationship_h__ */
156
157 /*
158   Local Variables:
159   c-basic-offset: 4
160   tab-width: 8
161   End:
162 */