The Gaudi Framework  v33r0 (d5ea422b)
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 157 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 162 of file semantics.py.

162  def __init__(self, cpp_type, name=None):
163  super(ComponentSemantics, self).__init__(cpp_type, name)
164  self.interfaces = cpp_type.split(':')
165  self.cpp_type = self.interfaces.pop(0)
166  self.interfaces = set(self.interfaces)
167 

Member Function Documentation

◆ default()

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

Definition at line 202 of file semantics.py.

202  def default(self, value):
203  return self.store(value)
204 
205 

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 168 of file semantics.py.

168  def store(self, value):
169  from . import Configurable, Configurables
170  if isinstance(value, Configurable):
171  value.name # make sure the configurable has a name
172  elif isinstance(value, basestring):
173  # try to map the sring to an existing Configurable
174  if value in Configurable.instances:
175  value = Configurable.instances[value]
176  else:
177  # or create one from type and name
178  if '/' in value:
179  t, n = value.split('/')
180  else:
181  t = n = value
182  value = Configurables.getByType(t).getInstance(n)
183  else:
184  raise TypeError(
185  'cannot assign {!r} to {!r}, requested string or {!r}'.format(
186  value, self.name, self.cpp_type))
187  if value.__component_type__ != self.cpp_type:
188  raise TypeError(
189  'wrong type for {!r}: expected {!r}, got {!r}'.format(
190  self.name, self.cpp_type, value.__component_type__))
191  try:
192  # if no interface is declared we cannot check
193  if value.__interfaces__:
194  if not self.interfaces.issubset(value.__interfaces__):
195  raise TypeError(
196  'wrong interfaces for {!r}: required {}'.format(
197  self.name, list(self.interfaces)))
198  except AttributeError:
199  pass # no interfaces declared by the configrable, cannot check
200  return value
201 
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119

Member Data Documentation

◆ __handled_types__

tuple GaudiConfig2.semantics.ComponentSemantics.__handled_types__
staticprivate
Initial value:
= ('Algorithm', 'Auditor',
re.compile(r'AlgTool(:I[a-zA-Z0-9_]*)*$'),
re.compile(r'Service(:I[a-zA-Z0-9_]*)*$'))

Definition at line 158 of file semantics.py.

◆ cpp_type

GaudiConfig2.semantics.ComponentSemantics.cpp_type

Definition at line 165 of file semantics.py.

◆ interfaces

GaudiConfig2.semantics.ComponentSemantics.interfaces

Definition at line 164 of file semantics.py.


The documentation for this class was generated from the following file: