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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 279 of file semantics.py.

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

Member Function Documentation

◆ default()

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

Definition at line 311 of file semantics.py.

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

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

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

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

Member Data Documentation

◆ __handled_types__

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

Definition at line 277 of file semantics.py.

◆ handle_type

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

Definition at line 281 of file semantics.py.


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