]> err.no Git - sope/blob - sope-appserver/NGXmlRpc/NGAsyncResultProxy.m
removed some libFoundation dependencies, cleaned up
[sope] / sope-appserver / NGXmlRpc / NGAsyncResultProxy.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo 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   OGo 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 OGo; 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 // $Id$
22
23 #include <NGXmlRpc/NGAsyncResultProxy.h>
24 #include "common.h"
25
26 @implementation NGAsyncResultProxy
27
28 - (void)dealloc {
29   [self->token  release];
30   [self->target release];
31   [self->result release];
32   [super dealloc];
33 }
34
35 /* accessors */
36
37 - (BOOL)isReady {
38   return self->isReady;
39 }
40 - (id)result {
41   return self->result;
42 }
43
44 - (void)setTarget:(id)_target {
45   ASSIGN(self->target, _target);
46 }
47 - (id)target {
48   return self->target;
49 }
50 - (void)setAction:(SEL)_action {
51   self->action = _action;
52 }
53 - (SEL)action {
54   return self->action;
55 }
56
57 - (void)setToken:(NSString *)_token {
58   ASSIGN(self->token, _token);
59 }
60 - (NSString *)token {
61   return self->token;
62 }
63
64 - (void)becameReady {
65   AUTORELEASE(self->keptObjects);
66   self->keptObjects = nil;
67
68   AUTORELEASE(RETAIN(self));
69   [self->target performSelector:self->action withObject:self];
70 }
71
72 - (void)postResult:(id)_result {
73   //[self logWithFormat:@"post result: %@", _result];
74   self->isReady = YES;
75   ASSIGN(self->result, _result);
76   [self becameReady];
77 }
78 - (void)postFaultResult:(NSException *)_result {
79   //[self logWithFormat:@"post fault result: %@", _result];
80   ASSIGN(self->result, _result);
81   self->isReady = YES;
82   [self becameReady];
83 }
84
85 - (void)retainObject:(id)_object {
86   if (self->keptObjects == nil)
87     self->keptObjects = [[NSMutableArray alloc] initWithCapacity:4];
88   [self->keptObjects addObject:_object];
89 }
90 - (void)releaseObject:(id)_object {
91   [[_object retain] autorelease];
92   [self->keptObjects removeObjectIdenticalTo:_object];
93 }
94
95 /* description */
96
97 - (NSString *)description {
98   NSMutableString *ms;
99
100   ms = [NSMutableString stringWithCapacity:128];
101   
102   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
103
104   if ([self isReady])
105     [ms appendFormat:@" ready=%@", self->result];
106   else
107     [ms appendString:@" pending"];
108   
109   [ms appendFormat:@" token=%@", self->token];
110   [ms appendFormat:@" target=%@", self->target];
111   
112   if ([self->keptObjects count] > 0)
113     [ms appendFormat:@" keeping=%@", self->keptObjects];
114   
115   [ms appendString:@">"];
116   
117   return ms;
118 }
119
120 @end /* NGAsyncResultProxy */