]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EODatabaseChannel.h
fixed bug in GDL adaptor lookup
[sope] / sope-gdl1 / GDLAccess / EODatabaseChannel.h
1 /* 
2    EODatabaseChannel.h
3
4    Copyright (C) 1996 Free Software Foundation, Inc.
5
6    Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
7    Date: 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 __EODatabaseChannel_h__
28 #define __EODatabaseChannel_h__
29
30 #import <Foundation/NSObject.h>
31
32 @class NSArray, NSMutableArray, NSDictionary, NSMutableDictionary;
33 @class NSString, NSMutableString, NSNotificationCenter;
34 @class EOAdaptor, EOAdaptorContext, EOAdaptorChannel;
35 @class EOEntity, EOSQLQualifier, EORelationship;
36 @class EOObjectUniquer, EODatabase, EODatabaseContext;
37 @class EOGlobalID;
38
39 extern NSString *EODatabaseChannelWillOpenNotificationName;
40 extern NSString *EODatabaseChannelDidOpenNotificationName;
41 extern NSString *EODatabaseChannelCouldNotOpenNotificationName;
42 extern NSString *EODatabaseChannelWillCloseNotificationName;
43 extern NSString *EODatabaseChannelDidCloseNotificationName;
44 extern NSString *EODatabaseChannelWillInsertObjectName;
45 extern NSString *EODatabaseChannelDidInsertObjectName;
46 extern NSString *EODatabaseChannelWillUpdateObjectName;
47 extern NSString *EODatabaseChannelDidUpdateObjectName;
48 extern NSString *EODatabaseChannelWillDeleteObjectName;
49 extern NSString *EODatabaseChannelDidDeleteObjectName;
50 extern NSString *EODatabaseChannelWillLockObjectName;
51 extern NSString *EODatabaseChannelDidLockObjectName;
52
53 @interface EODatabaseChannel : NSObject
54 {
55 @private
56   NSNotificationCenter *notificationCenter;
57   EOAdaptorChannel  *adaptorChannel;
58   EODatabaseContext *databaseContext;
59   id                delegate;
60   EOEntity          *currentEntity;
61   Class             currentClass;
62   NSArray           *currentAttributes;
63   NSArray           *currentRelations;
64   BOOL              currentReady;
65   id                currentEditingContext;
66   
67   /* statistics */
68   unsigned int successfulOpenCount;
69   unsigned int failedOpenCount;
70   unsigned int closeCount;
71   unsigned int insertCount;
72   unsigned int updateCount;
73   unsigned int deleteCount;
74   unsigned int lockCount;
75 }
76
77 // Initializing a new instance
78 - (id)initWithDatabaseContext:(EODatabaseContext*)aDatabaseContext;
79
80 // Getting the adaptor channel
81 - (EOAdaptorChannel*)adaptorChannel;
82
83 // Getting the database context
84 - (EODatabaseContext*)databaseContext;
85
86 // Setting the delegate
87 - (void)setDelegate:(id)aDelegate;
88 - (id)delegate;
89
90 // Opening and closing a channel
91 - (BOOL)isOpen;
92 - (BOOL)openChannel;
93 - (void)closeChannel;
94
95 // Modifying objects
96 - (BOOL)insertObject:(id)anObj;
97 - (BOOL)updateObject:(id)anObj;
98 - (BOOL)deleteObject:(id)anObj;
99 - (BOOL)lockObject:(id)anObj;
100 - (BOOL)refetchObject:(id)anObj;
101 - (id)allocateObjectForRow:(NSDictionary*)row
102   entity:(EOEntity*)anEntity
103   zone:(NSZone*)zone;
104 - (id)initializedObjectForRow:(NSDictionary*)row
105   entity:(EOEntity*)anEntity
106   zone:(NSZone*)zone;
107
108 // Fetching objects
109 - (BOOL)selectObjectsDescribedByQualifier:(EOSQLQualifier*)qualifier
110   fetchOrder:(NSArray*)fetchOrder;
111 - (id)fetchWithZone:(NSZone*)zone;
112 - (BOOL)isFetchInProgress;
113 - (void)cancelFetch;
114 - (void)setCurrentEntity:(EOEntity*)anEntity;
115
116 @end /* EODatabaseChannel */
117
118 /* statistics */
119
120 @interface EODatabaseChannel(Statistics)
121 - (unsigned int)successfulOpenCount;
122 - (unsigned int)failedOpenCount;
123 - (unsigned int)closeCount;
124 - (unsigned int)insertCount;
125 - (unsigned int)updateCount;
126 - (unsigned int)deleteCount;
127 - (unsigned int)lockCount;
128 @end
129
130 /*
131  * Delegate methods
132  */
133
134 @interface NSObject(EODatabaseChannelDelegateProtocol)
135
136 - (id)databaseChannel:aChannel
137   willInsertObject:anObj;
138 - (void)databaseChannel:aChannel
139   didInsertObject:anObj;
140 - (id)databaseChannel:aChannel
141   willDeleteObject:anObj;
142 - (void)databaseChannel:aChannel
143   didDeleteObject:anObj;
144 - (id)databaseChannel:aChannel
145   willUpdateObject:anObj;
146 - (void)databaseChannel:aChannel
147   didUpdateObject:anObj;
148 - (NSDictionary*)databaseChannel:aChannel
149   willRefetchObject:anObj;
150 - (NSDictionary*)databaseChannel:aChannel
151   didRefetchObject:anObj;
152 - (NSDictionary*)databaseChannel:aChannel
153   willRefetchObject:anObj
154   fromSnapshot:(NSDictionary*)snapshot;
155 - (NSDictionary*)databaseChannel:aChannel
156   willRefetchConflictingObject:anObj
157   withSnapshot:(NSMutableDictionary*)snapshot;
158 - (BOOL)databaseChannel:aChannel
159   willSelectObjectsDescribedByQualifier:(EOSQLQualifier*)qualifier
160   fetchOrder:(NSArray*)fetchOrder;
161 - (void)databaseChannel:aChannel
162   didSelectObjectsDescribedByQualifier:(EOSQLQualifier*)qualifier
163   fetchOrder:(NSArray*)fetchOrder;
164 - (void)databaseChannel:aChannel
165   willFetchObjectOfClass:(Class)class
166   withZone:(NSZone*)zone;
167 - (void)databaseChannel:aChannel
168   didFetchObject:anObj;
169 - databaseChannel:aChannel
170   willLockObject:anObj;
171 - (void)databaseChannel:aChannel
172   didLockObject:anObj;
173 - (Class)databaseChannel:aChannel
174   failedToLookupClassNamed:(const char*)name;
175 - (EORelationship*)databaseChannel:aChannel
176   relationshipForRow:(NSDictionary*)row 
177   relationship:(EORelationship*)relationship;
178
179 @end
180
181 @interface NSObject(EODatabaseChannelEONotifications)
182
183 - (BOOL)prepareForDeleteInChannel:(EODatabaseChannel *)_channel
184   context:(EODatabaseContext *)_ctx;
185 - (void)wasDeletedInChannel:(EODatabaseChannel *)_channel
186   context:(EODatabaseContext *)_ctx;
187
188 - (BOOL)prepareForInsertInChannel:(EODatabaseChannel *)_channel
189   context:(EODatabaseContext *)_ctx;
190 - (void)wasInsertedInChannel:(EODatabaseChannel *)_channel
191   context:(EODatabaseContext *)_ctx;
192
193 - (BOOL)prepareForUpdateInChannel:(EODatabaseChannel *)_channel
194   context:(EODatabaseContext *)_ctx;
195 - (void)wasUpdatedInChannel:(EODatabaseChannel *)_channel
196   context:(EODatabaseContext *)_ctx;
197
198 - (BOOL)prepareForLockInChannel:(EODatabaseChannel *)_channel
199   context:(EODatabaseContext *)_ctx;
200 - (void)wasLockedInChannel:(EODatabaseChannel *)_channel
201   context:(EODatabaseContext *)_ctx;
202   
203 @end
204
205 /*
206  * Object Awaking (EODatabaseChannelNotification protocol)
207  */
208
209 @interface NSObject(EODatabaseChannelNotification)
210 - (void)awakeForDatabaseChannel:(EODatabaseChannel*)channel;
211 @end
212
213 #endif /* __EODatabaseChannel_h__ */