59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#import <Foundation/NSUtilities.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSArray.h>
@implementation EOAdaptorContext
-- (id)initWithAdaptor :(EOAdaptor*)_adaptor
-{
- ASSIGN(self->adaptor, _adaptor);
- self->channels = [[NSMutableArray alloc] initWithCapacity:2];
- [self->adaptor contextDidInit:self];
- return self;
+- (id)initWithAdaptor:(EOAdaptor *)_adaptor {
+ ASSIGN(self->adaptor, _adaptor);
+ self->channels = [[NSMutableArray alloc] initWithCapacity:2];
+ [self->adaptor contextDidInit:self];
+ return self;
}
-- (void)dealloc
-{
- [self->adaptor contextWillDealloc:self];
- RELEASE(self->adaptor);
- RELEASE(self->channels);
- [super dealloc];
+- (void)dealloc {
+ [self->adaptor contextWillDealloc:self];
+ [self->adaptor release];
+ [self->channels release];
+ [super dealloc];
}
-- (EOAdaptorChannel*)createAdaptorChannel
-{
- return AUTORELEASE([[[adaptor adaptorChannelClass] alloc]
- initWithAdaptorContext:self]);
+/* channels */
+
+- (EOAdaptorChannel *)createAdaptorChannel {
+ return [[[[adaptor adaptorChannelClass] alloc]
+ initWithAdaptorContext:self] autorelease];
}
-- (NSArray *)channels
-{
+- (NSArray *)channels {
NSMutableArray *ma;
unsigned i, count;
return ma;
}
-- (void)channelDidInit:aChannel
-{
- [self->channels addObject:[NSValue valueWithNonretainedObject:aChannel]];
+- (void)channelDidInit:aChannel {
+ [self->channels addObject:[NSValue valueWithNonretainedObject:aChannel]];
}
-- (void)channelWillDealloc:(id)aChannel
-{
+- (void)channelWillDealloc:(id)aChannel {
int i;
for (i = [self->channels count] - 1; i >= 0; i--)
}
}
-- (BOOL)hasOpenChannels
-{
+- (BOOL)hasOpenChannels {
int i, count = [channels count];
for (i = 0; i < count; i++)
return NO;
}
-- (BOOL)hasBusyChannels
-{
+- (BOOL)hasBusyChannels {
int i, count = [channels count];
for (i = 0; i < count; i++)
return NO;
}
-- (BOOL)beginTransaction
-{
+/* transactions */
+
+- (BOOL)beginTransaction {
if (transactionNestingLevel && ![self canNestTransactions])
return NO;
if ([self->channels count] == 0)
return NO;
- if(delegateRespondsTo.willBegin) {
+ if (delegateRespondsTo.willBegin) {
EODelegateResponse response = [delegate adaptorContextWillBegin:self];
- if(response == EODelegateRejects)
+ if (response == EODelegateRejects)
return NO;
- else if(response == EODelegateOverrides)
+ else if (response == EODelegateOverrides)
return YES;
}
- if([self primaryBeginTransaction] == NO)
+ if ([self primaryBeginTransaction] == NO)
return NO;
[self transactionDidBegin];
- if(delegateRespondsTo.didBegin)
+ if (delegateRespondsTo.didBegin)
[delegate adaptorContextDidBegin:self];
return YES;
}
-- (BOOL)commitTransaction
-{
- if(!transactionNestingLevel || [self hasBusyChannels])
+- (BOOL)commitTransaction {
+ if (!transactionNestingLevel || [self hasBusyChannels])
return NO;
if (![channels count])
return NO;
- if(delegateRespondsTo.willCommit) {
+ if (delegateRespondsTo.willCommit) {
EODelegateResponse response = [delegate adaptorContextWillCommit:self];
- if(response == EODelegateRejects)
+ if (response == EODelegateRejects)
return NO;
- else if(response == EODelegateOverrides)
+ else if (response == EODelegateOverrides)
return YES;
}
- if([self primaryCommitTransaction] == NO)
+ if ([self primaryCommitTransaction] == NO)
return NO;
[self transactionDidCommit];
- if(delegateRespondsTo.didCommit)
+ if (delegateRespondsTo.didCommit)
[delegate adaptorContextDidCommit:self];
return YES;
}
-- (BOOL)rollbackTransaction
-{
- if(!transactionNestingLevel || [self hasBusyChannels])
+- (BOOL)rollbackTransaction {
+ if (!transactionNestingLevel || [self hasBusyChannels])
return NO;
if (![channels count])
return NO;
- if(delegateRespondsTo.willRollback) {
+ if (delegateRespondsTo.willRollback) {
EODelegateResponse response
= [delegate adaptorContextWillRollback:self];
- if(response == EODelegateRejects)
+ if (response == EODelegateRejects)
return NO;
- else if(response == EODelegateOverrides)
+ else if (response == EODelegateOverrides)
return YES;
}
- if([self primaryRollbackTransaction] == NO)
+ if ([self primaryRollbackTransaction] == NO)
return NO;
[self transactionDidRollback];
- if(delegateRespondsTo.didRollback)
+ if (delegateRespondsTo.didRollback)
[delegate adaptorContextDidRollback:self];
return YES;
}
-- (void)transactionDidBegin
-{
+- (void)transactionDidBegin {
/* Increment the transaction scope */
transactionNestingLevel++;
}
-- (void)transactionDidCommit
-{
+- (void)transactionDidCommit {
/* Decrement the transaction scope */
transactionNestingLevel--;
}
-- (void)transactionDidRollback
-{
+- (void)transactionDidRollback {
/* Decrement the transaction scope */
transactionNestingLevel--;
}
+/* delegate */
+
- (void)setDelegate:(id)_delegate {
self->delegate = _delegate;
return self->delegate;
}
+/* adaptor */
+
- (EOAdaptor *)adaptor {
return self->adaptor;
}
+
+/* transactions */
+
- (BOOL)canNestTransactions {
/* deprecated in WO 4.5 */
return NO;