OpenMPCD
Analysis
MPCDAnalysis
StarPolymersAnalysis
Registry.py
1
## The one and only instance of `Registry`.
2
registry =
None
3
4
class
Registry:
5
"""
6
Class that registers the various analysis tools for star polymers.
7
"""
8
9
def
__init__
(self):
10
"""
11
The constructor.
12
13
This is called automatically by the encolsing file, and must not be
14
called thereafter.
15
"""
16
if
registry
is
not
None
:
17
raise
Exception(
"Cannot create more than one instance"
)
18
19
from
collections
import
OrderedDict
20
self.
_registry
= OrderedDict()
21
22
23
def
register
(self, cls):
24
"""
25
Register the given class with the registry.
26
27
@param[in] cls The class to register.
28
"""
29
30
import
inspect
31
32
if
not
inspect.isclass(cls):
33
raise
ValueError()
34
35
if
cls.__name__
in
self.
_registry
:
36
raise
ValueError(
"Already in registry: "
+ cls.__name__)
37
38
self.
_registry
[cls.__name__] = cls
39
40
41
def
getRegisteredClasses
(self):
42
"""
43
Returns a dictionary of registered classes.
44
"""
45
46
return
self.
_registry
47
48
49
registry =
Registry
()
MPCDAnalysis.StarPolymersAnalysis.Registry.Registry._registry
_registry
Definition:
Registry.py:22
MPCDAnalysis.StarPolymersAnalysis.Registry.Registry
Definition:
Registry.py:8
MPCDAnalysis.StarPolymersAnalysis.Registry.Registry.__init__
def __init__(self)
Definition:
Registry.py:17
MPCDAnalysis.StarPolymersAnalysis.Registry.Registry.register
def register(self, cls)
Definition:
Registry.py:31
MPCDAnalysis.StarPolymersAnalysis.Registry.Registry.getRegisteredClasses
def getRegisteredClasses(self)
Definition:
Registry.py:48
Generated by
1.8.17