The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiConfig2.semantics.ComponentHandleSemantics Class Reference
Inheritance diagram for GaudiConfig2.semantics.ComponentHandleSemantics:
Collaboration diagram for GaudiConfig2.semantics.ComponentHandleSemantics:

Public Member Functions

 __init__ (self, cpp_type)
 store (self, value)
 default (self, value)
 merge (self, b, a)
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)

Public Attributes

 handle_type = getattr(GaudiKernel.GaudiHandles, self.cpp_type)
Public Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 cpp_type = cpp_type

Static Private Attributes

tuple __handled_types__ = ("PrivateToolHandle", "PublicToolHandle", "ServiceHandle")

Additional Inherited Members

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

Detailed Description

Semantics for component (tool, service) handles. On access, it will create the
corresponding Configurable instance and store it in the property.

Definition at line 309 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 317 of file semantics.py.

317 def __init__(self, cpp_type):
318 super().__init__(cpp_type)
319 self.handle_type = getattr(GaudiKernel.GaudiHandles, self.cpp_type)
320

Member Function Documentation

◆ default()

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

Definition at line 349 of file semantics.py.

349 def default(self, value):
350 return self.store(value)
351

◆ merge()

GaudiConfig2.semantics.ComponentHandleSemantics.merge ( self,
a,
b )
"Merge" two values.

Used when merging two Configurable instances, by default just ensure
the two values do not conflict, but it can be overridden in
derived semantics to, for example, append to the two lists.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 352 of file semantics.py.

352 def merge(self, b, a):
353 return a.merge(b)
354
355
int merge(const char *target, const char *source, bool fixup=false, bool dbg=true)
Definition merge.C:417

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 321 of file semantics.py.

321 def store(self, value):
322 # Configurable: store if correct type
323 if (
324 isinstance(value, Configurable)
325 and value.getGaudiType() == self.handle_type.componentType
326 ):
327 return value
328
329 # Handle: create Configurable
330 elif isinstance(value, GaudiHandle):
331 return (
332 Configurables.getByType(value.getType()).getInstance(value.getName())
333 if value.typeAndName
334 else self.handle_type() # empty handle
335 )
336
337 # Empty: empty Handle
338 elif value is None or value == "":
339 return self.handle_type()
340
341 # String: create Configurable
342 elif isinstance(value, str):
343 tn = value.split("/", maxsplit=1) # type[/name]
344 name = tn[1] if len(tn) == 2 else tn[0]
345 return Configurables.getByType(tn[0]).getInstance(name)
346
347 raise TypeError(f"cannot assign {value!r} ({type(value)}) to {self.name}")
348

Member Data Documentation

◆ __handled_types__

tuple GaudiConfig2.semantics.ComponentHandleSemantics.__handled_types__ = ("PrivateToolHandle", "PublicToolHandle", "ServiceHandle")
staticprivate

Definition at line 315 of file semantics.py.

◆ handle_type

GaudiConfig2.semantics.ComponentHandleSemantics.handle_type = getattr(GaudiKernel.GaudiHandles, self.cpp_type)

Definition at line 319 of file semantics.py.


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