aboutsummaryrefslogtreecommitdiff
path: root/util/ComponentRegistry.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/ComponentRegistry.py')
-rw-r--r--util/ComponentRegistry.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py
index f8fe00d..119ce18 100644
--- a/util/ComponentRegistry.py
+++ b/util/ComponentRegistry.py
@@ -1,17 +1,43 @@
import pdb
+#component registry, a singleton
+import thread
+#class ComponentRegistry:
+# def __init__(self):
+# self.regDict = {}
+# @staticmethod
+# def getRegistry(self):
+# if self.instance == None:
+# self.instance = self.__class__()
+# return self.instance
+# def registerComponent(component, cid=None):
+# if cid != None:
+# globals()['Registry'][cid] = component
+# else:
+# try:
+# cid = component['Id']
+# globals()['Registry'][cid] = component
+# except:
+# raise Exception('Must specify Id, component did not store it')
+#def registerDefault(
+def removeComponent(cid):
+ globals()['Registry'].pop(cid)
+def getComponent(cid):
+ return globals()['Registry'][cid]
#Registry of all components of the light system
#TODO: pick a graceful failure behavior and implement it
-registry = {}
+def initRegistry():
+ globals()['Registry'] = {}
def registerComponent(component, cid=None):
if cid != None:
- registry[cid] = component
+ globals()['Registry'][cid] = component
else:
try:
cid = component['Id']
- registry[cid] = component
+ globals()['Registry'][cid] = component
except:
raise Exception('Must specify Id, component did not store it')
+#def registerDefault(
def removeComponent(cid):
- registry.pop(cid)
+ globals()['Registry'].pop(cid)
def getComponent(cid):
- return registry[cid]
+ return globals()['Registry'][cid]