The Gaudi Framework  v36r11 (bdb84f5f)
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, name=None)
 
def store (self, value)
 
def default (self, value)
 
- Public Member Functions inherited from GaudiConfig2.semantics.PropertySemantics
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
 name
 
 cpp_type
 

Static Private Attributes

tuple __handled_types__
 

Detailed Description

Definition at line 204 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiConfig2.semantics.ComponentSemantics.__init__ (   self,
  cpp_type,
  name = None 
)

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 216 of file semantics.py.

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

Member Function Documentation

◆ default()

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

Definition at line 266 of file semantics.py.

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

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 225 of file semantics.py.

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

Member Data Documentation

◆ __handled_types__

tuple GaudiConfig2.semantics.ComponentSemantics.__handled_types__
staticprivate
Initial value:
= (
"Algorithm",
"Auditor",
re.compile(
r"AlgTool(:{})?$".format(_COMMA_SEPARATION_RE.format(exp=_NS_IDENT_RE))
),
re.compile(
r"Service(:{})?$".format(_COMMA_SEPARATION_RE.format(exp=_NS_IDENT_RE))
),
)

Definition at line 205 of file semantics.py.

◆ cpp_type

GaudiConfig2.semantics.ComponentSemantics.cpp_type

Definition at line 222 of file semantics.py.

◆ interfaces

GaudiConfig2.semantics.ComponentSemantics.interfaces

Definition at line 219 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