The Gaudi Framework  master (ad37f17d)
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 321 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 329 of file semantics.py.

329 def __init__(self, cpp_type):
330 super().__init__(cpp_type)
331 self.handle_type = getattr(GaudiKernel.GaudiHandles, self.cpp_type)
332

Member Function Documentation

◆ default()

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

Definition at line 361 of file semantics.py.

361 def default(self, value):
362 return self.store(value)
363

◆ 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 364 of file semantics.py.

364 def merge(self, b, a):
365 return a.merge(b)
366
367
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 333 of file semantics.py.

333 def store(self, value):
334 # Configurable: store if correct type
335 if (
336 isinstance(value, Configurable)
337 and value.getGaudiType() == self.handle_type.componentType
338 ):
339 return value
340
341 # Handle: create Configurable
342 elif isinstance(value, GaudiHandle):
343 return (
344 Configurables.getByType(value.getType()).getInstance(value.getName())
345 if value.typeAndName
346 else self.handle_type() # empty handle
347 )
348
349 # Empty: empty Handle
350 elif value is None or value == "":
351 return self.handle_type()
352
353 # String: create Configurable
354 elif isinstance(value, str):
355 tn = value.split("/", maxsplit=1) # type[/name]
356 name = tn[1] if len(tn) == 2 else tn[0]
357 return Configurables.getByType(tn[0]).getInstance(name)
358
359 raise TypeError(f"cannot assign {value!r} ({type(value)}) to {self.name}")
360

Member Data Documentation

◆ __handled_types__

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

Definition at line 327 of file semantics.py.

◆ handle_type

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

Definition at line 331 of file semantics.py.


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