The Gaudi Framework  v40r0 (475e45c1)
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 207 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 219 of file semantics.py.

219  def __init__(self, cpp_type):
220  super(ComponentSemantics, self).__init__(cpp_type)
221  if ":" in cpp_type:
222  self.cpp_type, self.interfaces = cpp_type.split(":", 1)
223  self.interfaces = set(self.interfaces.split(","))
224  else:
225  self.cpp_type = cpp_type
226  self.interfaces = set()
227 

Member Function Documentation

◆ default()

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

Definition at line 267 of file semantics.py.

267  def default(self, value):
268  return self.store(value)
269 
270 

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 228 of file semantics.py.

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

Member Data Documentation

◆ __handled_types__

GaudiConfig2.semantics.ComponentSemantics.__handled_types__
staticprivate

Definition at line 208 of file semantics.py.

◆ cpp_type

GaudiConfig2.semantics.ComponentSemantics.cpp_type

Definition at line 225 of file semantics.py.

◆ interfaces

GaudiConfig2.semantics.ComponentSemantics.interfaces

Definition at line 222 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:99