]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EOAttribute.h
fixed bug in GDL adaptor lookup
[sope] / sope-gdl1 / GDLAccess / EOAttribute.h
1 /* 
2    EOAttribute.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 __EOAttribute_h__
28 #define __EOAttribute_h__
29
30 #import <Foundation/NSString.h>
31 #import <Foundation/NSDictionary.h>
32 #import <Foundation/NSDate.h>
33
34 @class NSString, NSTimeZone, NSDate, NSException;
35 @class NSMutableArray;
36 @class EOEntity;
37
38 @interface EOAttribute : NSObject
39 {
40     NSString     *name;
41     NSString     *calendarFormat;
42     NSTimeZone   *clientTimeZone;
43     NSTimeZone   *serverTimeZone;
44     NSString     *columnName;
45     NSString     *definition;
46     NSString     *externalType;
47     NSString     *valueClassName;
48     NSString     *valueType;
49     NSString     *insertFormat;
50     NSString     *selectFormat;
51     NSString     *updateFormat;
52     NSDictionary *userDictionary;
53
54     /* Garbage collectable objects */
55     EOEntity       *entity;             /* non-retained */
56     NSMutableArray *definitionArray;    // These variables are meaningful only
57     EOAttribute    *realAttribute;      // if the attribute is flattened
58     unsigned       width;
59
60     struct {
61         BOOL    isReadOnly:1;
62         BOOL    isDerived:1;
63         BOOL    isFlattened:1;
64         BOOL    allowsNull:1;
65     } flags;
66 }
67
68 /* Initializing new instances */
69 - (id)initWithName:(NSString*)name;
70
71 /* Accessing the entity */
72 - (void)setEntity:(EOEntity*)entity;
73 - (EOEntity*)entity;
74 - (void)resetEntity;
75 - (BOOL)hasEntity;
76
77 /* Accessing the name */
78 - (BOOL)setName:(NSString*)name;
79 - (NSString*)name;
80 + (BOOL)isValidName:(NSString*)name;
81
82 /* Accessing date information */
83 + (NSString*)defaultCalendarFormat;
84 - (void)setCalendarFormat:(NSString*)format;
85 - (NSString*)calendarFormat;
86 - (void)setClientTimeZone:(NSTimeZone*)tz;
87 - (NSTimeZone*)clientTimeZone;
88 - (void)setServerTimeZone:(NSTimeZone*)tz;
89 - (NSTimeZone*)serverTimeZone;
90
91 /* Accessing external definitions */
92 - (void)setColumnName:(NSString*)columnName;
93 - (NSString*)columnName;
94 - (void)setDefinition:(NSString*)definition;
95 - (NSString*)definition;
96 - (NSMutableArray*)definitionArray;
97 - (void)setExternalType:(NSString*)type;
98 - (NSString*)externalType;
99
100 /* Accessing value type information */
101 - (void)setValueClassName:(NSString*)name;
102 - (NSString*)valueClassName;
103 - (void)setValueType:(NSString*)type;
104 - (NSString*)valueType;
105
106 /* Checking type information */
107 - (BOOL)referencesProperty:property;
108 - (BOOL)isDerived;
109 - (BOOL)isFlattened;
110 - (BOOL)setReadOnly:(BOOL)flag;
111 - (BOOL)isReadOnly;
112
113 /* Accessing SQL statement formats */
114 - (void)setInsertFormat:(NSString*)string;
115 - (NSString*)insertFormat;
116 - (void)setSelectFormat:(NSString*)string;
117 - (NSString*)selectFormat;
118 - (void)setUpdateFormat:(NSString*)string;
119 - (NSString*)updateFormat;
120
121 /* Accessing the user dictionary */
122 - (void)setUserDictionary:(NSDictionary*)dictionary;
123 - (NSDictionary*)userDictionary;
124
125 /* Obsolete. This method always return NO, because you should always release
126    a property. */
127 - (BOOL)referencesProperty:property;
128
129 @end
130
131
132 @interface EOAttribute (EOAttributePrivate)
133
134 + (EOAttribute*)attributeFromPropertyList:(id)propertyList;
135 - (void)replaceStringsWithObjects;
136 - (id)propertyList;
137
138 @end /* EOAttribute (EOAttributePrivate) */
139
140 @interface EOAttribute(ValuesConversion)
141
142 - (id)convertValue:(id)aValue
143   toClass:(Class)aClass
144   forType:(NSString *)aValueType;
145 - (id)convertValueToModel:(id)aValue;
146
147 @end /* EOAttribute (ValuesConversion) */
148
149 @interface NSString (EOAttributeTypeCheck)
150
151 - (BOOL)isNameOfARelationshipPath;
152
153 @end
154
155 @class NSMutableDictionary;
156
157 @interface EOAttribute(PropertyListCoding)
158
159 - (void)encodeIntoPropertyList:(NSMutableDictionary *)_plist;
160
161 @end
162
163 @interface EOAttribute(EOF2Additions)
164
165 - (void)beautifyName;
166
167 /* constraints */
168
169 - (void)setAllowsNull:(BOOL)_flag;
170 - (BOOL)allowsNull;
171 - (void)setWidth:(unsigned)_width;
172 - (unsigned)width;
173
174 - (NSException *)validateValue:(id *)_value;
175
176 - (NSString *)readFormat;
177 - (NSString *)writeFormat;
178
179 @end
180
181 #endif /* __EOAttribute_h__ */
182
183 /*
184   Local Variables:
185   c-basic-offset: 4
186   tab-width: 8
187   End:
188 */