API  1.0.0
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 
26 @implementation CPFunctionOperation : CPOperation
27 {
28  CPArray _functions;
29 }
30 
31 - (void)main
32 {
33  if (_functions && [_functions count] > 0)
34  {
35  var i = 0,
36  count = [_functions count];
37 
38  for (; i < count; i++)
39  {
40  var func = [_functions objectAtIndex:i];
41  func();
42  }
43  }
44 }
45 
46 - (id)init
47 {
48  self = [super init];
49 
50  if (self)
51  {
52  _functions = [];
53  }
54  return self;
55 }
56 
60 - (void)addExecutionFunction:(JSObject)jsFunction
61 {
62  [_functions addObject:jsFunction];
63 }
64 
68 - (CPArray)executionFunctions
69 {
70  return _functions;
71 }
72 
76 + (id)functionOperationWithFunction:(JSObject)jsFunction
77 {
78  functionOp = [[CPFunctionOperation alloc] init];
79  [functionOp addExecutionFunction:jsFunction];
80 
81  return functionOp;
82 }
83 
84 @end
id init()
Definition: CALayer.j:126
Represents an operation using a JavaScript function that can be run in an CPOperationQueue.
Represents an operation that can be run in an CPOperationQueue.
Definition: CPOperation.h:2
id alloc()
Definition: CPObject.j:130