The Gaudi Framework  v40r0 (475e45c1)
GaudiConfig2.semantics.ComponentHandleSemantics Class Reference
Inheritance diagram for GaudiConfig2.semantics.ComponentHandleSemantics:
Collaboration diagram for GaudiConfig2.semantics.ComponentHandleSemantics:

Public Member Functions

def __init__ (self, cpp_type)
 
def store (self, value)
 
def default (self, value)
 
def merge (self, b, a)
 
- Public Member Functions inherited from GaudiConfig2.semantics.PropertySemantics
def name (self)
 
def name (self, value)
 
def cpp_type (self)
 
def cpp_type (self, value)
 
def load (self, value)
 
def is_set (self, value)
 
def opt_value (self, value)
 

Public Attributes

 handle_type
 
- Public Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 cpp_type
 

Static Private Attributes

 __handled_types__
 

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__()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

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()

def 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()

def 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 

◆ store()

def 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__

GaudiConfig2.semantics.ComponentHandleSemantics.__handled_types__
staticprivate

Definition at line 277 of file semantics.py.

◆ handle_type

GaudiConfig2.semantics.ComponentHandleSemantics.handle_type

Definition at line 281 of file semantics.py.


The documentation for this class was generated from the following file:
gaudirun.default
default
Definition: gaudirun.py:188
merge
int merge(const char *target, const char *source, bool fixup=false, bool dbg=true)
Definition: merge.C:420
GaudiKernel.GaudiHandles
Definition: GaudiHandles.py:1