diff options
author | rcoh <rcoh@mit.edu> | 2010-12-22 14:27:33 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2010-12-22 14:27:33 -0500 |
commit | c581408f028d5b8ceadc53c68d7c1252fbe09e6d (patch) | |
tree | 8724862d05bde3bb3427cdff378cdb08da8babd2 /util/ComponentRegistry.py | |
parent | a1d9b85320c9b07d62470d78ef0c5f9015baf813 (diff) |
About halfway done with support for pixel regions. Modified the component registry a bit. Added
support for multiple pixel mappers (and along with that, default components). RCOH
Diffstat (limited to 'util/ComponentRegistry.py')
-rw-r--r-- | util/ComponentRegistry.py | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py index f8fe00d..119ce18 100644 --- a/util/ComponentRegistry.py +++ b/util/ComponentRegistry.py @@ -1,17 +1,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 -registry = {} +def initRegistry(): + globals()['Registry'] = {} def registerComponent(component, cid=None): if cid != None: - registry[cid] = component + globals()['Registry'][cid] = component else: try: cid = component['Id'] - registry[cid] = component + globals()['Registry'][cid] = component except: raise Exception('Must specify Id, component did not store it') +#def registerDefault( def removeComponent(cid): - registry.pop(cid) + globals()['Registry'].pop(cid) def getComponent(cid): - return registry[cid] + return globals()['Registry'][cid] |