The Gaudi Framework  master (adcf1ca6)
Loading...
Searching...
No Matches
GaudiConfig2.semantics.ComponentSemantics Class Reference
Inheritance diagram for GaudiConfig2.semantics.ComponentSemantics:
Collaboration diagram for GaudiConfig2.semantics.ComponentSemantics:

Public Member Functions

 __init__ (self, cpp_type)
 
 store (self, value)
 
 default (self, value)
 
- Public Member Functions inherited from GaudiConfig2.semantics.PropertySemantics
 __init__ (self, cpp_type)
 
 name (self)
 
 name (self, value)
 
 cpp_type (self)
 
 cpp_type (self, value)
 
 load (self, value)
 
 is_set (self, value)
 
 opt_value (self, value)
 
 merge (self, a, b)
 

Public Attributes

 interfaces = cpp_type.split(":", 1)
 
- Public Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 cpp_type = cpp_type
 

Static Private Attributes

tuple __handled_types__
 

Additional Inherited Members

- Protected Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 _name = None
 
 _cpp_type = value
 

Detailed Description

Definition at line 208 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 220 of file semantics.py.

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

Member Function Documentation

◆ default()

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

Definition at line 268 of file semantics.py.

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

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 229 of file semantics.py.

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

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

◆ interfaces

GaudiConfig2.semantics.ComponentSemantics.interfaces = cpp_type.split(":", 1)

Definition at line 223 of file semantics.py.


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