4 Copyright (C) 1996 Free Software Foundation, Inc.
6 Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
9 This file is part of the GNUstep Database Library.
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.
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.
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.
27 #ifndef __EODatabaseChannel_h__
28 #define __EODatabaseChannel_h__
30 #import <Foundation/NSObject.h>
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;
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;
53 @interface EODatabaseChannel : NSObject
56 NSNotificationCenter *notificationCenter;
57 EOAdaptorChannel *adaptorChannel;
58 EODatabaseContext *databaseContext;
60 EOEntity *currentEntity;
62 NSArray *currentAttributes;
63 NSArray *currentRelations;
65 id currentEditingContext;
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;
77 // Initializing a new instance
78 - (id)initWithDatabaseContext:(EODatabaseContext*)aDatabaseContext;
80 // Getting the adaptor channel
81 - (EOAdaptorChannel*)adaptorChannel;
83 // Getting the database context
84 - (EODatabaseContext*)databaseContext;
86 // Setting the delegate
87 - (void)setDelegate:(id)aDelegate;
90 // Opening and closing a channel
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
104 - (id)initializedObjectForRow:(NSDictionary*)row
105 entity:(EOEntity*)anEntity
109 - (BOOL)selectObjectsDescribedByQualifier:(EOSQLQualifier*)qualifier
110 fetchOrder:(NSArray*)fetchOrder;
111 - (id)fetchWithZone:(NSZone*)zone;
112 - (BOOL)isFetchInProgress;
114 - (void)setCurrentEntity:(EOEntity*)anEntity;
116 @end /* EODatabaseChannel */
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;
134 @interface NSObject(EODatabaseChannelDelegateProtocol)
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
173 - (Class)databaseChannel:aChannel
174 failedToLookupClassNamed:(const char*)name;
175 - (EORelationship*)databaseChannel:aChannel
176 relationshipForRow:(NSDictionary*)row
177 relationship:(EORelationship*)relationship;
181 @interface NSObject(EODatabaseChannelEONotifications)
183 - (BOOL)prepareForDeleteInChannel:(EODatabaseChannel *)_channel
184 context:(EODatabaseContext *)_ctx;
185 - (void)wasDeletedInChannel:(EODatabaseChannel *)_channel
186 context:(EODatabaseContext *)_ctx;
188 - (BOOL)prepareForInsertInChannel:(EODatabaseChannel *)_channel
189 context:(EODatabaseContext *)_ctx;
190 - (void)wasInsertedInChannel:(EODatabaseChannel *)_channel
191 context:(EODatabaseContext *)_ctx;
193 - (BOOL)prepareForUpdateInChannel:(EODatabaseChannel *)_channel
194 context:(EODatabaseContext *)_ctx;
195 - (void)wasUpdatedInChannel:(EODatabaseChannel *)_channel
196 context:(EODatabaseContext *)_ctx;
198 - (BOOL)prepareForLockInChannel:(EODatabaseChannel *)_channel
199 context:(EODatabaseContext *)_ctx;
200 - (void)wasLockedInChannel:(EODatabaseChannel *)_channel
201 context:(EODatabaseContext *)_ctx;
206 * Object Awaking (EODatabaseChannelNotification protocol)
209 @interface NSObject(EODatabaseChannelNotification)
210 - (void)awakeForDatabaseChannel:(EODatabaseChannel*)channel;
213 #endif /* __EODatabaseChannel_h__ */