root/branches/Carsten_PtrWork2/Tools/convScript/OperationBundle.py

Revision 151, 1.2 kB (checked in by cneumann, 2 years ago)

added: script for mechanical code conversions

Line 
1
2 from OperationRegistry import OperationRegistry
3
4 class OperationBundle:
5     """ Bundles a bunch of operations to be applied together.
6     """
7    
8     #### member
9     #  opList -- list of operations
10     
11     def __init__(self):
12         self.opList = [];
13    
14     # add an operation
15     def addOp(self, opName):
16         op = OperationRegistry.getRegisteredOp(opName);
17        
18         if op == None:
19             print "ERROR: addOp called with unknown op \"%s\"" % opName;
20        
21         op.addSelf(self);
22    
23     # remove an operation
24     def subOp(self, opName):
25         op = OperationRegistry.getRegisteredOp(opName);
26        
27         if op == None:
28             print "ERROR: subOp called with unknown op \"%s\"" % opName;
29        
30         op.subSelf(self);
31        
32     def applyBundle(self, driver):
33         for op in self.opList:
34             op.applyOp(driver);
35        
36     ###############################
37     # Internal
38     
39     # add op to the list of enabled ones (unless it already is in it)
40     def internal_addOp(self, op):
41         if op not in self.opList:
42             self.opList.append(op);
43    
44     # remove op from the list of enables ones
45     def internal_subOp(self, op):
46         if op in self.opList:
47             self.opList.remove(op);
Note: See TracBrowser for help on using the browser.