The Gaudi Framework  v36r1 (3e2fb5a8)
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 162 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 169 of file semantics.py.

169  def __init__(self, cpp_type, name=None):
170  super(ComponentSemantics, self).__init__(cpp_type, name)
171  if ':' in cpp_type:
172  self.cpp_type, self.interfaces = cpp_type.split(':', 1)
173  self.interfaces = set(self.interfaces.split(","))
174  else:
175  self.cpp_type = cpp_type
176  self.interfaces = set()
177 

Member Function Documentation

◆ default()

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

Definition at line 212 of file semantics.py.

212  def default(self, value):
213  return self.store(value)
214 
215 

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 178 of file semantics.py.

178  def store(self, value):
179  from . import Configurable, Configurables
180  if isinstance(value, Configurable):
181  value.name # make sure the configurable has a name
182  elif isinstance(value, basestring):
183  # try to map the sring to an existing Configurable
184  if value in Configurable.instances:
185  value = Configurable.instances[value]
186  else:
187  # or create one from type and name
188  if '/' in value:
189  t, n = value.split('/')
190  else:
191  t = n = value
192  value = Configurables.getByType(t).getInstance(n)
193  else:
194  raise TypeError(
195  'cannot assign {!r} to {!r}, requested string or {!r}'.format(
196  value, self.name, self.cpp_type))
197  if value.__component_type__ != self.cpp_type:
198  raise TypeError(
199  'wrong type for {!r}: expected {!r}, got {!r}'.format(
200  self.name, self.cpp_type, value.__component_type__))
201  try:
202  # if no interface is declared we cannot check
203  if value.__interfaces__:
204  if not self.interfaces.issubset(value.__interfaces__):
205  raise TypeError(
206  'wrong interfaces for {!r}: required {}'.format(
207  self.name, list(self.interfaces)))
208  except AttributeError:
209  pass # no interfaces declared by the configrable, cannot check
210  return value
211 

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

◆ cpp_type

GaudiConfig2.semantics.ComponentSemantics.cpp_type

Definition at line 175 of file semantics.py.

◆ interfaces

GaudiConfig2.semantics.ComponentSemantics.interfaces

Definition at line 172 of file semantics.py.


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