aboutsummaryrefslogtreecommitdiff
path: root/util/ComponentRegistry.py
blob: f8fe00d5fdeb1fb807c152d394c341e23b194123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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]