|
Revision 151, 1.6 kB
(checked in by cneumann, 2 years ago)
|
added: script for mechanical code conversions
|
| Line | |
|---|
| 1 |
class OperationRegistry: |
|---|
| 2 |
""" Registry of available operations. |
|---|
| 3 |
""" |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
regOpMap = {}; |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
@staticmethod |
|---|
| 13 |
def registerOp(opInstance): |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
opName = opInstance.getName(); |
|---|
| 17 |
if not OperationRegistry.regOpMap.has_key(opName): |
|---|
| 18 |
OperationRegistry.regOpMap[opName] = opInstance; |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
@staticmethod |
|---|
| 22 |
def unregisterOp(opInstance): |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
opName = opInstance.getName(); |
|---|
| 26 |
if OperationRegistry.regOpMap.has_key(opName): |
|---|
| 27 |
OperationRegistry.regOpMap.pop(opName); |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
@staticmethod |
|---|
| 31 |
def getRegisteredOp(opName): |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
if OperationRegistry.regOpMap.has_key(opName): |
|---|
| 35 |
return OperationRegistry.regOpMap[opName]; |
|---|
| 36 |
|
|---|
| 37 |
return None; |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
@staticmethod |
|---|
| 41 |
def getRegisteredOpList(): |
|---|
| 42 |
return OperationRegistry.regOpMap.values(); |
|---|
| 43 |
|
|---|
| 44 |
def registerOperation(opInstance, group = None): |
|---|
| 45 |
""" Helper for operation registration, if group is not None, the operation |
|---|
| 46 |
opInstance is also added to the given group. |
|---|
| 47 |
""" |
|---|
| 48 |
OperationRegistry.registerOp(opInstance); |
|---|
| 49 |
if group != None: |
|---|
| 50 |
group.addOp(opInstance.getName()); |
|---|