]> err.no Git - sope/blob - sope-appserver/NGXmlRpc/NGAsyncResultProxy.m
fixed (all?) gcc 4.0 warnings
[sope] / sope-appserver / NGXmlRpc / NGAsyncResultProxy.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include <NGXmlRpc/NGAsyncResultProxy.h>
23 #include "common.h"
24
25 @implementation NGAsyncResultProxy
26
27 - (void)dealloc {
28   [self->token  release];
29   [self->target release];
30   [self->result release];
31   [super dealloc];
32 }
33
34 /* accessors */
35
36 - (BOOL)isReady {
37   return self->isReady;
38 }
39 - (id)result {
40   return self->result;
41 }
42
43 - (void)setTarget:(id)_target {
44   ASSIGN(self->target, _target);
45 }
46 - (id)target {
47   return self->target;
48 }
49 - (void)setAction:(SEL)_action {
50   self->action = _action;
51 }
52 - (SEL)action {
53   return self->action;
54 }
55
56 - (void)setToken:(NSString *)_token {
57   ASSIGN(self->token, _token);
58 }
59 - (NSString *)token {
60   return self->token;
61 }
62
63 - (void)becameReady {
64   AUTORELEASE(self->keptObjects);
65   self->keptObjects = nil;
66
67   AUTORELEASE(RETAIN(self));
68   [self->target performSelector:self->action withObject:self];
69 }
70
71 - (void)postResult:(id)_result {
72   //[self logWithFormat:@"post result: %@", _result];
73   self->isReady = YES;
74   ASSIGN(self->result, _result);
75   [self becameReady];
76 }
77 - (void)postFaultResult:(NSException *)_result {
78   //[self logWithFormat:@"post fault result: %@", _result];
79   ASSIGN(self->result, _result);
80   self->isReady = YES;
81   [self becameReady];
82 }
83
84 - (void)retainObject:(id)_object {
85   if (self->keptObjects == nil)
86     self->keptObjects = [[NSMutableArray alloc] initWithCapacity:4];
87   [self->keptObjects addObject:_object];
88 }
89 - (void)releaseObject:(id)_object {
90   [[_object retain] autorelease];
91   [self->keptObjects removeObjectIdenticalTo:_object];
92 }
93
94 /* description */
95
96 - (NSString *)description {
97   NSMutableString *ms;
98
99   ms = [NSMutableString stringWithCapacity:128];
100   
101   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
102
103   if ([self isReady])
104     [ms appendFormat:@" ready=%@", self->result];
105   else
106     [ms appendString:@" pending"];
107   
108   [ms appendFormat:@" token=%@", self->token];
109   [ms appendFormat:@" target=%@", self->target];
110   
111   if ([self->keptObjects count] > 0)
112     [ms appendFormat:@" keeping=%@", self->keptObjects];
113   
114   [ms appendString:@">"];
115   
116   return ms;
117 }
118
119 @end /* NGAsyncResultProxy */