3 import GaudiConfig2.semantics
4 from GaudiKernel.DataHandle
import DataHandle
10 Extend the mapping-semantics with a merge-method that merges two mappings as long as they do not have different values for the same key
11 Use 'mapMergeNoReplace<T>' as fifth parameter of the Gaudi::Property<T> constructor
12 to invoke this merging method.
14 __handled_types__ = (re.compile(
r"^mapMergeNoReplace<.*>$"),)
16 super(MapMergeNoReplaceSemantics, self).
__init__(cpp_type)
20 if k
in a
and b[k] != a[k]:
21 raise ValueError(
'conflicting values in map under key %r and %r %r' % (k, b[k], a[k]))
28 Semantics for all data handle keys (Read, Write, Decor, Cond).
30 __handled_types__ = (re.compile(
r"SG::.*HandleKey<.*>$"),)
35 self.
_type =
next(GaudiConfig2.semantics.extract_template_args(cpp_type))
38 if cpp_type.startswith(
"SG::Read"):
40 elif cpp_type.startswith(
"SG::Write"):
43 raise TypeError(f
"C++ type {cpp_type} not supported")
46 if isinstance(value, DataHandle):
48 elif isinstance(value, str):
51 raise TypeError(f
"cannot assign {value!r} ({type(value)}) to {self.name}"
52 ", expected string or DataHandle")
58 Treat VarHandleKeyArrays like arrays of strings
60 __handled_types__ = (
"SG::VarHandleKeyArray",)
63 """Semantics for an item (DataHandle) in a VarHandleKeyArray converting to string"""
69 if isinstance(value, DataHandle):
71 elif isinstance(value, str):
74 raise TypeError(f
"cannot assign {value!r} ({type(value)}) to {self.name}"
75 ", expected string or DataHandle")
87 from AthenaServices.ItemListSemantics
import OutputStreamItemListSemantics
89 GaudiConfig2.semantics.SEMANTICS.append(VarHandleKeySemantics)
90 GaudiConfig2.semantics.SEMANTICS.append(VarHandleArraySematics)
91 GaudiConfig2.semantics.SEMANTICS.append(MapMergeNoReplaceSemantics)
92 GaudiConfig2.semantics.SEMANTICS.append(OutputStreamItemListSemantics)