API  1.0.0
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 
26 @implementation CPInvocationOperation : CPOperation
27 {
28  CPInvocation _invocation;
29 }
30 
31 
32 - (void)main
33 {
34  if (_invocation)
35  {
36  [_invocation invoke];
37  }
38 }
39 
40 - (id)init
41 {
42  if (self = [super init])
43  {
44  _invocation = nil;
45  }
46  return self;
47 }
48 
53 - (id)initWithInvocation:(CPInvocation)inv
54 {
55  if (self = [self init])
56  {
57  _invocation = inv;
58  }
59 
60  return self;
61 }
62 
69 - (id)initWithTarget:(id)target selector:(SEL)sel object:(id)arg
70 {
71  var inv = [[CPInvocation alloc] initWithMethodSignature:nil];
72  [inv setTarget:target];
73  [inv setSelector:sel];
74  [inv setArgument:arg atIndex:2];
75 
76  return [self initWithInvocation:inv];
77 }
78 
82 - (CPInvocation)invocation
83 {
84  return _invocation;
85 }
86 
90 - (id)result
91 {
92  if ([self isFinished] && _invocation)
93  {
94  return [_invocation returnValue];
95  }
96 
97  return nil;
98 }
99 
100 @end
void setArgument:atIndex:(id anArgument, [atIndex] CPUInteger anIndex)
Definition: CPInvocation.j:106
id init()
Definition: CALayer.j:126
An object representation of a message.
Definition: CPInvocation.h:2
void setTarget:(id aTarget)
Definition: CPInvocation.j:88
void setSelector:(SEL aSelector)
Definition: CPInvocation.j:71
Represents an operation that can be run in an CPOperationQueue.
Definition: CPOperation.h:2
id initWithMethodSignature:(CPMethodSignature aMethodSignature)
Definition: CPInvocation.j:53
id initWithInvocation:(CPInvocation inv)
Represents an operation using an invocation that can be run in an CPOperationQueue.
id alloc()
Definition: CPObject.j:130