The Gaudi Framework  master (69bbfe1b)
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 255 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 263 of file semantics.py.

263 def __init__(self, cpp_type):
264 super().__init__(cpp_type)
265 if ":" in cpp_type:
266 self.cpp_type, self.interfaces = cpp_type.split(":", 1)
267 self.interfaces = set(self.interfaces.split(","))
268 else:
269 self.cpp_type = cpp_type
270 self.interfaces = set()
271

Member Function Documentation

◆ default()

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

Definition at line 305 of file semantics.py.

305 def default(self, value):
306 return self.store(value)
307
308

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 272 of file semantics.py.

272 def store(self, value):
273 if isinstance(value, Configurable):
274 value.name # make sure the configurable has a name
275 elif isinstance(value, str):
276 # try to map the sring to an existing Configurable
277 if value in Configurable.instances:
278 value = Configurable.instances[value]
279 else:
280 # or create one from type and name
281 if "/" in value:
282 t, n = value.split("/")
283 else:
284 t = n = value
285 value = Configurables.getByType(t).getInstance(n)
286 else:
287 raise TypeError(
288 f"cannot assign {value!r} to {self.name!r}, requested string or {self.cpp_type!r}"
289 )
290 if value.__component_type__ != self.cpp_type:
291 raise TypeError(
292 f"wrong type for {self.name!r}: expected {self.cpp_type!r}, got {value.__component_type__!r}"
293 )
294 try:
295 # if no interface is declared we cannot check
296 if value.__interfaces__:
297 if not self.interfaces.issubset(value.__interfaces__):
298 raise TypeError(
299 f"wrong interfaces for {self.name!r}: required {list(self.interfaces)}"
300 )
301 except AttributeError:
302 pass # no interfaces declared by the configrable, cannot check
303 return value
304

Member Data Documentation

◆ __handled_types__

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

Definition at line 256 of file semantics.py.

◆ interfaces

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

Definition at line 266 of file semantics.py.


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