API 0.9.5
Foundation/CPInvocationOperation.j
Go to the documentation of this file.
00001 /*
00002  * CPInvocationOperation.j
00003  *
00004  * Created by Johannes Fahrenkrug.
00005  * Copyright 2009, Springenwerk.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 
00027 @implementation CPInvocationOperation : CPOperation
00028 {
00029     CPInvocation _invocation;
00030 }
00031 
00032 
00033 - (void)main
00034 {
00035     if (_invocation)
00036     {
00037         [_invocation invoke];
00038     }
00039 }
00040 
00041 - (id)init
00042 {
00043     if (self = [super init])
00044     {
00045         _invocation = nil;
00046     }
00047     return self;
00048 }
00049 
00054 - (id)initWithInvocation:(CPInvocation)inv
00055 {
00056     if (self = [self init])
00057     {
00058         _invocation = inv;
00059     }
00060 
00061     return self;
00062 }
00063 
00070 - (id)initWithTarget:(id)target selector:(SEL)sel object:(id)arg
00071 {
00072     var inv = [[CPInvocation alloc] initWithMethodSignature:nil];
00073     [inv setTarget:target];
00074     [inv setSelector:sel];
00075     [inv setArgument:arg atIndex:2];
00076 
00077     return [self initWithInvocation:inv];
00078 }
00079 
00083 - (CPInvocation)invocation
00084 {
00085     return _invocation;
00086 }
00087 
00091 - (id)result
00092 {
00093     if ([self isFinished] && _invocation)
00094     {
00095         return [_invocation returnValue];
00096     }
00097 
00098     return nil;
00099 }
00100 
00101 @end
 All Classes Files Functions Variables Defines