The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
GaudiConfig2.semantics.ComponentSemantics Class Reference
Inheritance diagram for GaudiConfig2.semantics.ComponentSemantics:
Collaboration diagram for GaudiConfig2.semantics.ComponentSemantics:

Public Member Functions

 __init__ (self, cpp_type)
 
 store (self, value)
 
 default (self, value)
 
- Public Member Functions inherited from GaudiConfig2.semantics.PropertySemantics
 __init__ (self, cpp_type)
 
 name (self)
 
 name (self, value)
 
 cpp_type (self)
 
 cpp_type (self, value)
 
 load (self, value)
 
 is_set (self, value)
 
 opt_value (self, value)
 
 merge (self, a, b)
 

Public Attributes

 interfaces = cpp_type.split(":", 1)
 
- Public Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 cpp_type = cpp_type
 

Static Private Attributes

tuple __handled_types__
 

Additional Inherited Members

- Protected Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 _name = None
 
 _cpp_type = value
 

Detailed Description

Definition at line 207 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

GaudiConfig2.semantics.ComponentSemantics.__init__ ( self,
cpp_type )

Definition at line 219 of file semantics.py.

219 def __init__(self, cpp_type):
220 super(ComponentSemantics, self).__init__(cpp_type)
221 if ":" in cpp_type:
222 self.cpp_type, self.interfaces = cpp_type.split(":", 1)
223 self.interfaces = set(self.interfaces.split(","))
224 else:
225 self.cpp_type = cpp_type
226 self.interfaces = set()
227

Member Function Documentation

◆ default()

GaudiConfig2.semantics.ComponentSemantics.default ( self,
value )

Definition at line 267 of file semantics.py.

267 def default(self, value):
268 return self.store(value)
269
270

◆ store()

GaudiConfig2.semantics.ComponentSemantics.store ( self,
value )
Validation/transformation of the data to be stored.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 228 of file semantics.py.

228 def store(self, value):
229 if isinstance(value, Configurable):
230 value.name # make sure the configurable has a name
231 elif isinstance(value, str):
232 # try to map the sring to an existing Configurable
233 if value in Configurable.instances:
234 value = Configurable.instances[value]
235 else:
236 # or create one from type and name
237 if "/" in value:
238 t, n = value.split("/")
239 else:
240 t = n = value
241 value = Configurables.getByType(t).getInstance(n)
242 else:
243 raise TypeError(
244 "cannot assign {!r} to {!r}, requested string or {!r}".format(
245 value, self.name, self.cpp_type
246 )
247 )
248 if value.__component_type__ != self.cpp_type:
249 raise TypeError(
250 "wrong type for {!r}: expected {!r}, got {!r}".format(
251 self.name, self.cpp_type, value.__component_type__
252 )
253 )
254 try:
255 # if no interface is declared we cannot check
256 if value.__interfaces__:
257 if not self.interfaces.issubset(value.__interfaces__):
258 raise TypeError(
259 "wrong interfaces for {!r}: required {}".format(
260 self.name, list(self.interfaces)
261 )
262 )
263 except AttributeError:
264 pass # no interfaces declared by the configrable, cannot check
265 return value
266
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition MsgStream.cpp:93

Member Data Documentation

◆ __handled_types__

tuple GaudiConfig2.semantics.ComponentSemantics.__handled_types__
staticprivate
Initial value:
= (
"Algorithm",
"Auditor",
re.compile(
r"AlgTool(:{})?$".format(_COMMA_SEPARATION_RE.format(exp=_NS_IDENT_RE))
),
re.compile(
r"Service(:{})?$".format(_COMMA_SEPARATION_RE.format(exp=_NS_IDENT_RE))
),
)

Definition at line 208 of file semantics.py.

◆ interfaces

GaudiConfig2.semantics.ComponentSemantics.interfaces = cpp_type.split(":", 1)

Definition at line 222 of file semantics.py.


The documentation for this class was generated from the following file: