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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 280 of file semantics.py.

280 def __init__(self, cpp_type):
281 super().__init__(cpp_type)
282 self.handle_type = getattr(GaudiKernel.GaudiHandles, self.cpp_type)
283

Member Function Documentation

◆ default()

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

Definition at line 312 of file semantics.py.

312 def default(self, value):
313 return self.store(value)
314

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

315 def merge(self, b, a):
316 return a.merge(b)
317
318
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 284 of file semantics.py.

284 def store(self, value):
285 # Configurable: store if correct type
286 if (
287 isinstance(value, Configurable)
288 and value.getGaudiType() == self.handle_type.componentType
289 ):
290 return value
291
292 # Handle: create Configurable
293 elif isinstance(value, GaudiHandle):
294 return (
295 Configurables.getByType(value.getType()).getInstance(value.getName())
296 if value.typeAndName
297 else self.handle_type() # empty handle
298 )
299
300 # Empty: empty Handle
301 elif value is None or value == "":
302 return self.handle_type()
303
304 # String: create Configurable
305 elif isinstance(value, str):
306 tn = value.split("/", maxsplit=1) # type[/name]
307 name = tn[1] if len(tn) == 2 else tn[0]
308 return Configurables.getByType(tn[0]).getInstance(name)
309
310 raise TypeError(f"cannot assign {value!r} ({type(value)}) to {self.name}")
311

Member Data Documentation

◆ __handled_types__

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

Definition at line 278 of file semantics.py.

◆ handle_type

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

Definition at line 282 of file semantics.py.


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