API  0.9.6
 All Classes Files Functions Variables Macros Groups Pages
CPFunctionOperation.j
Go to the documentation of this file.
1 /*
2  * CPFunctionOperation.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 CPFunctionOperation : CPOperation
28 {
29  CPArray _functions;
30 }
31 
32 - (void)main
33 {
34  if (_functions && [_functions count] > 0)
35  {
36  var i = 0,
37  count = [_functions count];
38 
39  for (; i < count; i++)
40  {
41  var func = [_functions objectAtIndex:i];
42  func();
43  }
44  }
45 }
46 
47 - (id)init
48 {
49  self = [super init];
50 
51  if (self)
52  {
53  _functions = [];
54  }
55  return self;
56 }
57 
61 - (void)addExecutionFunction:(JSObject)jsFunction
62 {
63  [_functions addObject:jsFunction];
64 }
65 
69 - (CPArray)executionFunctions
70 {
71  return _functions;
72 }
73 
77 + (id)functionOperationWithFunction:(JSObject)jsFunction
78 {
79  functionOp = [[CPFunctionOperation alloc] init];
80  [functionOp addExecutionFunction:jsFunction];
81 
82  return functionOp;
83 }
84 
85 @end