aboutsummaryrefslogtreecommitdiff
path: root/util/ComponentRegistry.py
blob: 119ce18c990ee1a83c0cf784f962ddd53cf66ce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
def initRegistry():
    globals()['Registry'] = {}
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]