The Gaudi Framework  master (37c0b60a)
GaudiConfig2.semantics.ComponentSemantics Class Reference
Inheritance diagram for GaudiConfig2.semantics.ComponentSemantics:
Collaboration diagram for GaudiConfig2.semantics.ComponentSemantics:

Public Member Functions

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

Public Attributes

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

Static Private Attributes

 __handled_types__
 

Detailed Description

Definition at line 202 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 214 of file semantics.py.

214  def __init__(self, cpp_type):
215  super(ComponentSemantics, self).__init__(cpp_type)
216  if ":" in cpp_type:
217  self.cpp_type, self.interfaces = cpp_type.split(":", 1)
218  self.interfaces = set(self.interfaces.split(","))
219  else:
220  self.cpp_type = cpp_type
221  self.interfaces = set()
222 

Member Function Documentation

◆ default()

def GaudiConfig2.semantics.ComponentSemantics.default (   self,
  value 
)

Definition at line 264 of file semantics.py.

264  def default(self, value):
265  return self.store(value)
266 
267 

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 223 of file semantics.py.

223  def store(self, value):
224  from . import Configurable, Configurables
225 
226  if isinstance(value, Configurable):
227  value.name # make sure the configurable has a name
228  elif isinstance(value, str):
229  # try to map the sring to an existing Configurable
230  if value in Configurable.instances:
231  value = Configurable.instances[value]
232  else:
233  # or create one from type and name
234  if "/" in value:
235  t, n = value.split("/")
236  else:
237  t = n = value
238  value = Configurables.getByType(t).getInstance(n)
239  else:
240  raise TypeError(
241  "cannot assign {!r} to {!r}, requested string or {!r}".format(
242  value, self.name, self.cpp_type
243  )
244  )
245  if value.__component_type__ != self.cpp_type:
246  raise TypeError(
247  "wrong type for {!r}: expected {!r}, got {!r}".format(
248  self.name, self.cpp_type, value.__component_type__
249  )
250  )
251  try:
252  # if no interface is declared we cannot check
253  if value.__interfaces__:
254  if not self.interfaces.issubset(value.__interfaces__):
255  raise TypeError(
256  "wrong interfaces for {!r}: required {}".format(
257  self.name, list(self.interfaces)
258  )
259  )
260  except AttributeError:
261  pass # no interfaces declared by the configrable, cannot check
262  return value
263 

Member Data Documentation

◆ __handled_types__

GaudiConfig2.semantics.ComponentSemantics.__handled_types__
staticprivate

Definition at line 203 of file semantics.py.

◆ cpp_type

GaudiConfig2.semantics.ComponentSemantics.cpp_type

Definition at line 220 of file semantics.py.

◆ interfaces

GaudiConfig2.semantics.ComponentSemantics.interfaces

Definition at line 217 of file semantics.py.


The documentation for this class was generated from the following file:
gaudirun.default
default
Definition: gaudirun.py:188
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119