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 __eoaccess_EODatabase_h__
28 #define __eoaccess_EODatabase_h__
30 #import <Foundation/NSObject.h>
31 #import <Foundation/NSDate.h>
34 @class NSMutableArray;
36 @class NSMutableDictionary;
38 @class NSMutableString;
44 @class EOObjectUniquer;
45 @class EODatabase, EODatabaseContext, EODatabaseChannel;
47 @protocol EOObjectRegistry
49 - (void)forgetObject:(id)anObj;
50 - (id)objectForPrimaryKey:(NSDictionary *)aKey entity:(EOEntity *)anEntity;
52 /* retrieving snapshots and primary keys */
54 - (NSDictionary *)snapshotForObject:(id)anObj;
55 - (NSDictionary *)primaryKeyForObject:(id)anObj;
56 - (void)primaryKey:(NSDictionary **)aKey
57 andSnapshot:(NSDictionary **)aSnapshot
60 /* recording objects */
62 - (void)recordObject:(id)anObj
63 primaryKey:(NSDictionary *)aKey
64 snapshot:(NSDictionary *)aSnapshot;
66 - (void)recordObject:(id)anObj
67 primaryKey:(NSDictionary *)aKey
68 entity:(EOEntity *)anEntity
69 snapshot:(NSDictionary *)aSnapshot;
73 @interface EODatabase : NSObject < EOObjectRegistry >
77 EOObjectUniquer *objectsDictionary;
78 NSMutableArray *contexts;
81 BOOL isUniquingObjects:1;
82 BOOL isKeepingSnapshots:1;
83 BOOL isLoggingWarnings:1;
87 // Initializing new instances
88 - (id)initWithAdaptor:(EOAdaptor *)anAdaptor;
89 - (id)initWithModel:(EOModel *)aModel;
91 // Getting the adaptor
92 - (EOAdaptor*)adaptor;
94 // Getting the database contexts
98 // Checking connection status
99 - (BOOL)hasOpenChannels;
101 // Uniquing/snapshotting
102 - (void)setUniquesObjects:(BOOL)yn;
103 - (BOOL)uniquesObjects;
104 - (void)setKeepsSnapshots:(BOOL)yn;
105 - (BOOL)keepsSnapshots;
108 + (void)forgetObject:(id)anObj;
109 - (void)forgetAllObjects;
110 - (void)forgetAllSnapshots;
112 - (BOOL)isObject:(id)anObj updatedOutsideContext:(EODatabaseContext *)aContext;
115 - (BOOL)logsErrorMessages;
116 - (void)setLogsErrorMessages:(BOOL)yn;
117 - (void)reportError:(NSString*)error;
118 - (void)reportErrorFormat:(NSString*)format, ...;
119 - (void)reportErrorFormat:(NSString*)format arguments:(va_list)arguments;
121 @end /* EODatabase */
124 * Methods used by database classes internally
127 @interface EODatabase(Private)
128 - (void)contextDidInit:(id)aContext;
129 - (void)contextWillDealloc:(id)aContext;
130 - (EOObjectUniquer*)objectUniquer;
135 extern NSTimeInterval NSDistantPastTimeInterval;
137 @interface EODatabase(EOF2Additions)
142 - (void)addModel:(EOModel *)_model;
143 - (BOOL)addModelIfCompatible:(EOModel *)_model;
147 - (EOEntity *)entityForObject:(id)_object;
148 - (EOEntity *)entityNamed:(NSString *)_name;
152 - (void)recordSnapshot:(NSDictionary *)_snapshot forGlobalID:(EOGlobalID *)_gid;
153 - (void)recordSnapshots:(NSDictionary *)_snapshots;
155 - (void)recordSnapshot:(NSArray *)_gids
156 forSourceGlobalID:(EOGlobalID *)_gid
157 relationshipName:(NSString *)_name;
158 - (void)recordToManySnapshots:(NSDictionary *)_snapshots;
160 - (NSDictionary *)snapshotForGlobalID:(EOGlobalID *)_gid
161 after:(NSTimeInterval)_duration;
162 - (NSDictionary *)snapshotForGlobalID:(EOGlobalID *)_gid;
164 - (void)forgetSnapshotsForGlobalIDs:(NSArray *)_gids;
165 - (void)forgetSnapshotsForGlobalID:(EOGlobalID *)_gid;
169 #endif /* __eoaccess_EODatabase_h__ */