aboutsummaryrefslogtreecommitdiff
path: root/util/ComponentRegistry.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2010-12-20 14:19:09 -0500
committerGravatar rcoh <rcoh@mit.edu>2010-12-20 14:19:09 -0500
commit7386cbc7ce48e3996d92d84cff3d1a4dab8f538d (patch)
treec6093fb305efc46ee3b73728206653892a670c14 /util/ComponentRegistry.py
parenta89c772cd64c6790906734f7128947e0f453c7e3 (diff)
A little bit more util stuff. Migrated the component registry to the ComponentRegistry module.
Almost done.
Diffstat (limited to 'util/ComponentRegistry.py')
-rw-r--r--util/ComponentRegistry.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py
new file mode 100644
index 0000000..f8fe00d
--- /dev/null
+++ b/util/ComponentRegistry.py
@@ -0,0 +1,17 @@
+import pdb
+#Registry of all components of the light system
+#TODO: pick a graceful failure behavior and implement it
+registry = {}
+def registerComponent(component, cid=None):
+ if cid != None:
+ registry[cid] = component
+ else:
+ try:
+ cid = component['Id']
+ registry[cid] = component
+ except:
+ raise Exception('Must specify Id, component did not store it')
+def removeComponent(cid):
+ registry.pop(cid)
+def getComponent(cid):
+ return registry[cid]