API  0.9.6
 All Classes Files Functions Variables Macros Groups Pages
CPInvocationOperation.j
Go to the documentation of this file.
1 /*
2  * CPInvocationOperation.j
3  *
4  * Created by Johannes Fahrenkrug.
5  * Copyright 2009, Springenwerk.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 
27 @implementation CPInvocationOperation : CPOperation
28 {
29  CPInvocation _invocation;
30 }
31 
32 
33 - (void)main
34 {
35  if (_invocation)
36  {
37  [_invocation invoke];
38  }
39 }
40 
41 - (id)init
42 {
43  if (self = [super init])
44  {
45  _invocation = nil;
46  }
47  return self;
48 }
49 
54 - (id)initWithInvocation:(CPInvocation)inv
55 {
56  if (self = [self init])
57  {
58  _invocation = inv;
59  }
60 
61  return self;
62 }
63 
70 - (id)initWithTarget:(id)target selector:(SEL)sel object:(id)arg
71 {
72  var inv = [[CPInvocation alloc] initWithMethodSignature:nil];
73  [inv setTarget:target];
74  [inv setSelector:sel];
75  [inv setArgument:arg atIndex:2];
76 
77  return [self initWithInvocation:inv];
78 }
79 
83 - (CPInvocation)invocation
84 {
85  return _invocation;
86 }
87 
91 - (id)result
92 {
93  if ([self isFinished] && _invocation)
94  {
95  return [_invocation returnValue];
96  }
97 
98  return nil;
99 }
100 
101 @end