00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 @import <Foundation/CPObject.j>
00023 @import "CPOperation.j"
00024
00025
00030 @implementation CPFunctionOperation : CPOperation
00031 {
00032 CPArray _functions;
00033 }
00034
00035
00036 - (void)main
00037 {
00038 if (_functions && [_functions count] > 0)
00039 {
00040 var i = 0;
00041 for (i = 0; i < [_functions count]; i++)
00042 {
00043 var func = [_functions objectAtIndex:i];
00044 func();
00045 }
00046 }
00047 }
00048
00049 - (id)init
00050 {
00051 if (self = [super init])
00052 {
00053 _functions = [];
00054 }
00055 return self;
00056 }
00057
00061 - (void)addExecutionFunction:(JSObject)jsFunction
00062 {
00063 [_functions addObject:jsFunction];
00064 }
00065
00069 - (CPArray)executionFunctions
00070 {
00071 return _functions;
00072 }
00073
00077 + (id)functionOperationWithFunction:(JSObject)jsFunction
00078 {
00079 functionOp = [[CPFunctionOperation alloc] init];
00080 [functionOp addExecutionFunction:jsFunction];
00081
00082 return functionOp;
00083 }
00084
00085 @end