The Gaudi Framework  master (76fc3702)
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 257 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 269 of file semantics.py.

269 def __init__(self, cpp_type):
270 super(ComponentSemantics, self).__init__(cpp_type)
271 if ":" in cpp_type:
272 self.cpp_type, self.interfaces = cpp_type.split(":", 1)
273 self.interfaces = set(self.interfaces.split(","))
274 else:
275 self.cpp_type = cpp_type
276 self.interfaces = set()
277

Member Function Documentation

◆ default()

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

Definition at line 317 of file semantics.py.

317 def default(self, value):
318 return self.store(value)
319
320

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 278 of file semantics.py.

278 def store(self, value):
279 if isinstance(value, Configurable):
280 value.name # make sure the configurable has a name
281 elif isinstance(value, str):
282 # try to map the sring to an existing Configurable
283 if value in Configurable.instances:
284 value = Configurable.instances[value]
285 else:
286 # or create one from type and name
287 if "/" in value:
288 t, n = value.split("/")
289 else:
290 t = n = value
291 value = Configurables.getByType(t).getInstance(n)
292 else:
293 raise TypeError(
294 "cannot assign {!r} to {!r}, requested string or {!r}".format(
295 value, self.name, self.cpp_type
296 )
297 )
298 if value.__component_type__ != self.cpp_type:
299 raise TypeError(
300 "wrong type for {!r}: expected {!r}, got {!r}".format(
301 self.name, self.cpp_type, value.__component_type__
302 )
303 )
304 try:
305 # if no interface is declared we cannot check
306 if value.__interfaces__:
307 if not self.interfaces.issubset(value.__interfaces__):
308 raise TypeError(
309 "wrong interfaces for {!r}: required {}".format(
310 self.name, list(self.interfaces)
311 )
312 )
313 except AttributeError:
314 pass # no interfaces declared by the configrable, cannot check
315 return value
316
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 258 of file semantics.py.

◆ interfaces

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

Definition at line 272 of file semantics.py.


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