aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2011-01-10 23:24:02 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2011-01-10 23:24:02 -0500
commitaaf8bdbee7fdc1d4721f43307fc824c373c69ec4 (patch)
treeee22f0ac45dede7fa8263cfc91f2730b19d07da9 /util
parenta1969e4c4bf61bc6e73c6a59fbef96e8ce361611 (diff)
some improvements to behavior chain. A "Square" Behavior
Diffstat (limited to 'util')
-rw-r--r--util/ComponentRegistry.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py
index 0518f56..43c4795 100644
--- a/util/ComponentRegistry.py
+++ b/util/ComponentRegistry.py
@@ -4,14 +4,18 @@ from logger import main_log
#TODO: make component registry a singleton
def initRegistry():
#TODO: don't overwrite existing registry
- globals()['Registry'] = {}
+ if not 'Registry' in globals():
+ globals()['Registry'] = {}
def clearRegistry():
initRegistry()
+
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
def registerComponent(component, cid=None):
@@ -26,11 +30,13 @@ def registerComponent(component, cid=None):
main_log.debug(cid + 'automatically assigned')
globals()['Registry'][cid] = component
return cid
-#def registerDefault(
+
def removeComponent(cid):
globals()['Registry'].pop(cid)
+
def getComponent(cid):
return globals()['Registry'][cid]
+
def getNewId():
trialKey = len(globals()['Registry'])
trialId = hashlib.md5(str(trialKey)).hexdigest()