API 0.9.5
Foundation/CPFunctionOperation.j
Go to the documentation of this file.
00001 /*
00002  * CPFunctionOperation.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 CPFunctionOperation : CPOperation
00028 {
00029     CPArray _functions;
00030 }
00031 
00032 - (void)main
00033 {
00034     if (_functions && [_functions count] > 0)
00035     {
00036         var i = 0,
00037             count = [_functions count];
00038 
00039         for (; i < count; i++)
00040         {
00041             var func = [_functions objectAtIndex:i];
00042             func();
00043         }
00044     }
00045 }
00046 
00047 - (id)init
00048 {
00049     self = [super init];
00050 
00051     if (self)
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
 All Classes Files Functions Variables Defines