]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EODatabaseContext.h
renamed PostgreSQL72 to PostgreSQL, install in Library/GDLAdaptors-1.1
[sope] / sope-gdl1 / GDLAccess / EODatabaseContext.h
1 /* 
2    EODatabaseContext.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 __EODatabaseContext_h__
28 #define __EODatabaseContext_h__
29
30 #import <Foundation/NSObject.h>
31 #import <GDLAccess/EODatabase.h>
32
33 @class NSArray, NSMutableArray, NSDictionary, NSMutableDictionary;
34 @class NSString, NSMutableString;
35 @class EOAdaptorContext;
36 @class EOEntity;
37 @class EOObjectUniquer, EODatabase, EODatabaseContext, EODatabaseChannel;
38
39 typedef enum {
40     EOUpdateWithOptimisticLocking,
41     EOUpdateWithPessimisticLocking,
42     EOUpdateWithNoLocking,
43     EONoUpdate,
44 } EOUpdateStrategy;
45
46 struct _EOTransactionScope;
47
48 extern NSString *EODatabaseContextWillBeginTransactionName;
49 extern NSString *EODatabaseContextDidBeginTransactionName;
50 extern NSString *EODatabaseContextWillRollbackTransactionName;
51 extern NSString *EODatabaseContextDidRollbackTransactionName;
52 extern NSString *EODatabaseContextWillCommitTransactionName;
53 extern NSString *EODatabaseContextDidCommitTransactionName;
54
55 struct EODatabaseContextModificationQueue;
56
57 @interface EODatabaseContext : NSObject < EOObjectRegistry >
58 //EOCooperatingObjectStore < EOObjectRegistry >
59 {
60   EOAdaptorContext *adaptorContext;
61   EODatabase       *database;
62   NSMutableArray   *channels;
63   EOUpdateStrategy updateStrategy;
64   id               coordinator;
65   id               delegate; /* non-retained */
66
67   struct _EOTransactionScope *transactionStackTop;
68   int                        transactionNestingLevel;
69         
70   // These fields should be in a bitfield but are ivars for debug purposes
71   BOOL isKeepingSnapshots;
72   BOOL isUniquingObjects;
73
74   /* modified objects */
75   struct EODatabaseContextModificationQueue *ops;
76
77   /* statistics */
78   unsigned int txBeginCount;
79   unsigned int txCommitCount;
80   unsigned int txRollbackCount;
81 }
82
83 // Initializing instances
84 - (id)initWithDatabase:(EODatabase *)aDatabase;
85
86 /* accessors */
87
88 - (void)setDelegate:(id)_delegate;
89 - (id)delegate;
90 - (EODatabase *)database;
91
92 // Getting the adaptor context
93 - (EOAdaptorContext*)adaptorContext;
94
95 // Finding channels
96 - (BOOL)hasBusyChannels;
97 - (BOOL)hasOpenChannels;
98 - (NSArray *)channels;
99 - (id)createChannel;
100
101 // Controlling transactions
102 - (BOOL)beginTransaction;
103 - (BOOL)commitTransaction;
104 - (BOOL)rollbackTransaction;
105
106 // Notifying of other transactions
107 - (void)transactionDidBegin;
108 - (void)transactionDidCommit;
109 - (void)transactionDidRollback;
110
111 // Nesting transactions
112 - (BOOL)canNestTransactions;
113 - (unsigned)transactionNestingLevel; 
114
115 // Setting the update strategy
116 - (void)setUpdateStrategy:(EOUpdateStrategy)aStrategy;
117 - (EOUpdateStrategy)updateStrategy;
118 - (BOOL)keepsSnapshots;
119
120 // Handle Objects
121
122 - (void)recordLockedObject:(id)anObj;
123 - (BOOL)isObjectLocked:(id)anObj;
124 - (void)recordUpdatedObject:(id)anObj;
125 - (BOOL)isObjectUpdated:(id)anObj;
126
127 @end /* EODatabaseContext */
128
129 @interface EODatabaseContext(Statistics)
130
131 - (unsigned int)transactionBeginCount;
132 - (unsigned int)transactionCommitCount;
133 - (unsigned int)transactionRollbackCount;
134
135 @end
136
137 /*
138  * Methods used by database classess internally
139  */
140
141 @interface EODatabaseContext(Private)
142 - (void)channelDidInit:(id)aChannel;
143 - (void)channelWillDealloc:(id)aChannel;
144 - (void)privateBeginTransaction;
145 - (void)privateCommitTransaction;
146 - (void)privateRollbackTransaction;
147 @end
148
149 @class EOModel;
150
151 @interface EODatabaseContext(NewInEOF2)
152
153 + (void)setContextClassToRegister:(Class)_cclass;
154 + (Class)contextClassToRegister;
155
156 #if 0
157 + (EODatabaseContext *)registeredDatabaseContextForModel:(EOModel *)_model
158   editingContext:(id)_ec;
159
160 - (id)coordinator;
161 #endif
162
163 /* managing channels */
164
165 - (EODatabaseChannel *)availableChannel;
166 - (NSArray *)registeredChannels;
167 - (void)registerChannel:(EODatabaseChannel *)_channel;
168 - (void)unregisterChannel:(EODatabaseChannel *)_channel;
169
170 @end
171
172 @class EOFetchSpecification;
173
174 @interface NSObject(EOF2DelegateMethods)
175
176 - (BOOL)databaseContext:(EODatabaseContext *)_ctx
177   shouldSelectObjectsWithFetchSpecification:(EOFetchSpecification *)_fspec
178   databaseChannel:(EODatabaseChannel *)_channel;
179
180 - (void)databaseContext:(EODatabaseContext *)_ctx
181   didSelectObjectsWithFetchSpecification:(EOFetchSpecification *)_fspec
182   databaseChannel:(EODatabaseChannel *)_channel;
183
184 - (BOOL)databaseContext:(EODatabaseContext *)_ctx
185   shouldUsePessimisticLockWithFetchSpecification:(EOFetchSpecification *)_fspec
186   databaseChannel:(EODatabaseChannel *)_channel;
187
188 @end
189
190 #endif /* __EODatabaseContext_h__ */