diff options
Diffstat (limited to 'util/ComponentRegistry.py')
-rw-r--r-- | util/ComponentRegistry.py | 17 |
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] |