]> err.no Git - sope/blob - sope-gdl1/FrontBase2/FBContext.m
fix for lF
[sope] / sope-gdl1 / FrontBase2 / FBContext.m
1 /* 
2    FBContext.m
3
4    Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
5
6    Author: Helge Hess (helge.hess@mdlink.de)
7
8    This file is part of the FB Adaptor Library
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Library General Public
12    License as published by the Free Software Foundation; either
13    version 2 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Library General Public License for more details.
19
20    You should have received a copy of the GNU Library General Public
21    License along with this library; see the file COPYING.LIB.
22    If not, write to the Free Software Foundation,
23    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25 // $Id: FBContext.m 1 2004-08-20 10:38:46Z znek $
26
27 #import "FBContext.h"
28 #import "FBChannel.h"
29 #import "common.h"
30
31 @implementation FBContext
32
33 static FBContext *context = nil;
34
35 + (FBContext *)activeContext {
36   return context;
37 }
38
39 - (void)channelDidInit:_channel {
40   if ([channels count] > 0) {
41     [NSException raise:@"TooManyOpenChannelsException"
42                  format:@"SybaseAdaptor10 only supports one channel per context"];
43   }
44   [super channelDidInit:_channel];
45 }
46
47 - (BOOL)primaryBeginTransaction {
48   return YES;
49 }
50
51 - (BOOL)primaryCommitTransaction {
52   FrontBaseChannel *channel;
53   BOOL result;
54   
55   context = self;
56   channel = [[channels lastObject] nonretainedObjectValue];
57   //NSLog(@"committing channel %@", channel);
58   result  = [channel evaluateExpression:@"COMMIT"];
59   context = nil;
60   return result;
61 }
62
63 - (BOOL)primaryRollbackTransaction {
64   FrontBaseChannel *channel;
65   BOOL result;
66   
67   context = self;
68   channel = [[channels lastObject] nonretainedObjectValue];
69   //NSLog(@"rolling back channel %@", channel);
70   result  = [channel evaluateExpression:@"ROLLBACK"];
71   context = nil;
72   return result;
73 }
74
75 - (BOOL)canNestTransactions {
76   return YES;
77 }
78
79 // NSCopying methods
80
81 - (id)copyWithZone:(NSZone *)zone {
82   // copy is needed during creation of NSNotification object
83   return RETAIN(self);
84 }
85
86 @end
87
88 @implementation FrontBaseContext
89 @end
90
91 void __link_FBContext() {
92   // used to force linking of object file
93   __link_FBContext();
94 }