]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EODatabase.h
fixed bug in GDL adaptor lookup
[sope] / sope-gdl1 / GDLAccess / EODatabase.h
1 /* 
2    EODatabase.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 __eoaccess_EODatabase_h__
28 #define __eoaccess_EODatabase_h__
29
30 #import <Foundation/NSObject.h>
31 #import <Foundation/NSDate.h>
32
33 @class NSArray;
34 @class NSMutableArray;
35 @class NSDictionary;
36 @class NSMutableDictionary;
37 @class NSString;
38 @class NSMutableString;
39
40 @class EOAdaptor;
41 @class EOModel;
42 @class EOEntity;
43
44 @class EOObjectUniquer;
45 @class EODatabase, EODatabaseContext, EODatabaseChannel;
46
47 @protocol EOObjectRegistry
48
49 - (void)forgetObject:(id)anObj;
50 - (id)objectForPrimaryKey:(NSDictionary *)aKey entity:(EOEntity *)anEntity;
51
52 /* retrieving snapshots and primary keys */
53
54 - (NSDictionary *)snapshotForObject:(id)anObj;
55 - (NSDictionary *)primaryKeyForObject:(id)anObj;
56 - (void)primaryKey:(NSDictionary **)aKey
57   andSnapshot:(NSDictionary **)aSnapshot
58   forObject:(id)anObj;
59
60 /* recording objects */
61
62 - (void)recordObject:(id)anObj
63   primaryKey:(NSDictionary *)aKey 
64   snapshot:(NSDictionary *)aSnapshot;
65
66 - (void)recordObject:(id)anObj
67   primaryKey:(NSDictionary *)aKey
68   entity:(EOEntity *)anEntity
69   snapshot:(NSDictionary *)aSnapshot;
70
71 @end
72
73 @interface EODatabase : NSObject < EOObjectRegistry >
74 {
75   @private
76     EOAdaptor       *adaptor;
77     EOObjectUniquer *objectsDictionary;
78     NSMutableArray  *contexts;
79     
80     struct {
81         BOOL isUniquingObjects:1;
82         BOOL isKeepingSnapshots:1;
83         BOOL isLoggingWarnings:1;
84     } flags;
85 }
86
87 // Initializing new instances
88 - (id)initWithAdaptor:(EOAdaptor *)anAdaptor;
89 - (id)initWithModel:(EOModel *)aModel;
90
91 // Getting the adaptor
92 - (EOAdaptor*)adaptor;
93
94 // Getting the database contexts
95 - (id)createContext;
96 - (NSArray*)contexts;
97
98 // Checking connection status
99 - (BOOL)hasOpenChannels;
100
101 // Uniquing/snapshotting
102 - (void)setUniquesObjects:(BOOL)yn;
103 - (BOOL)uniquesObjects;
104 - (void)setKeepsSnapshots:(BOOL)yn;
105 - (BOOL)keepsSnapshots;
106
107 // Handle Objects
108 + (void)forgetObject:(id)anObj;
109 - (void)forgetAllObjects;
110 - (void)forgetAllSnapshots;
111
112 - (BOOL)isObject:(id)anObj updatedOutsideContext:(EODatabaseContext *)aContext;
113
114 // Error messages
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;
120
121 @end /* EODatabase */
122
123 /*
124  * Methods used by database classes internally
125  */
126
127 @interface EODatabase(Private)
128 - (void)contextDidInit:(id)aContext;
129 - (void)contextWillDealloc:(id)aContext;
130 - (EOObjectUniquer*)objectUniquer;
131 @end
132
133 @class EOGlobalID;
134
135 extern NSTimeInterval NSDistantPastTimeInterval;
136
137 @interface EODatabase(EOF2Additions)
138
139 /* models */
140
141 - (NSArray *)models;
142 - (void)addModel:(EOModel *)_model;
143 - (BOOL)addModelIfCompatible:(EOModel *)_model;
144
145 /* entities */
146
147 - (EOEntity *)entityForObject:(id)_object;
148 - (EOEntity *)entityNamed:(NSString *)_name;
149
150 /* snapshots */
151
152 - (void)recordSnapshot:(NSDictionary *)_snapshot forGlobalID:(EOGlobalID *)_gid;
153 - (void)recordSnapshots:(NSDictionary *)_snapshots;
154
155 - (void)recordSnapshot:(NSArray *)_gids
156   forSourceGlobalID:(EOGlobalID *)_gid
157   relationshipName:(NSString *)_name;
158 - (void)recordToManySnapshots:(NSDictionary *)_snapshots;
159
160 - (NSDictionary *)snapshotForGlobalID:(EOGlobalID *)_gid
161   after:(NSTimeInterval)_duration;
162 - (NSDictionary *)snapshotForGlobalID:(EOGlobalID *)_gid;
163
164 - (void)forgetSnapshotsForGlobalIDs:(NSArray *)_gids;
165 - (void)forgetSnapshotsForGlobalID:(EOGlobalID *)_gid;
166
167 @end
168
169 #endif /* __eoaccess_EODatabase_h__ */