ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaConfiguration
python
AtlasSemantics.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
import
GaudiConfig2.semantics
4
from
GaudiKernel.DataHandle
import
DataHandle
5
import
re
6
7
8
class
VarHandleKeySemantics
(GaudiConfig2.semantics.PropertySemantics):
9
'''
10
Semantics for all data handle keys (Read, Write, Decor, Cond).
11
'''
12
__handled_types__ = (re.compile(
r"SG::.*HandleKey<.*>$"
),)
13
14
def
__init__
(self, cpp_type):
15
super().
__init__
(cpp_type)
16
# Deduce actual handle type
17
self.
_type
= next(GaudiConfig2.semantics.extract_template_args(cpp_type))
18
self.
_isCond
=
'CondHandle'
in
cpp_type
19
20
if
cpp_type.startswith(
"SG::Read"
):
21
self.
_mode
=
"R"
22
elif
cpp_type.startswith(
"SG::Write"
):
23
self.
_mode
=
"W"
24
else
:
25
raise
TypeError(f
"C++ type {cpp_type} not supported"
)
26
27
def
store
(self, value):
28
if
isinstance(value, DataHandle):
29
v = value.Path
30
elif
isinstance(value, str):
31
v = value
32
else
:
33
raise
TypeError(f
"cannot assign {value!r} ({type(value)}) to {self.name}"
34
", expected string or DataHandle"
)
35
return
DataHandle(v, self.
_mode
, self.
_type
, self.
_isCond
)
36
37
38
class
VarHandleArraySematics
(GaudiConfig2.semantics.SequenceSemantics):
39
'''
40
Treat VarHandleKeyArrays like arrays of strings
41
'''
42
__handled_types__ = (re.compile(
r"SG::HandleKeyArray<.*>$"
),)
43
44
class
_ItemSemantics
(GaudiConfig2.semantics.StringSemantics):
45
"""Semantics for an item (DataHandle) in a VarHandleKeyArray converting to string"""
46
47
def
__init__
(self):
48
super().
__init__
(
"std::string"
)
49
50
def
store
(self, value):
51
if
isinstance(value, DataHandle):
52
return
value.Path
53
elif
isinstance(value, str):
54
return
value
55
else
:
56
raise
TypeError(f
"cannot assign {value!r} ({type(value)}) to {self.name}"
57
", expected string or DataHandle"
)
58
59
def
__init__
(self, cpp_type):
60
super().
__init__
(cpp_type, valueSem = self.
_ItemSemantics
())
61
62
# Example for cpp_type:
63
# SG::HandleKeyArray<SG::ReadHandle<HiveDataObj>, SG::ReadHandleKey<HiveDataObj>,
64
# (Gaudi::DataHandle::Mode)4>
65
handle_type = next(GaudiConfig2.semantics.extract_template_args(cpp_type))
66
self.
_type
= next(GaudiConfig2.semantics.extract_template_args(handle_type))
67
self.
_isCond
=
'CondHandle'
in
handle_type
68
69
if
handle_type.startswith(
"SG::ReadHandle"
):
70
self.
_mode
=
"R"
71
elif
handle_type.startswith(
"SG::WriteHandle"
):
72
self.
_mode
=
"W"
73
else
:
74
raise
TypeError(f
"C++ type {cpp_type} not supported"
)
75
76
def
merge
(self,bb,aa):
77
for
b
in
bb:
78
if
b
not
in
aa:
79
aa.append(b)
80
return
aa
81
82
83
from
AthenaServices.ItemListSemantics
import
OutputStreamItemListSemantics
84
from
GeneratorConfig.GeneratorSettingsSemantics
import
GeneratorSettingsSemantics
85
86
GaudiConfig2.semantics.SEMANTICS.append(VarHandleKeySemantics)
87
GaudiConfig2.semantics.SEMANTICS.append(VarHandleArraySematics)
88
GaudiConfig2.semantics.SEMANTICS.append(OutputStreamItemListSemantics)
89
GaudiConfig2.semantics.SEMANTICS.append(GeneratorSettingsSemantics)
python.AtlasSemantics.VarHandleArraySematics._ItemSemantics
Definition
AtlasSemantics.py:44
python.AtlasSemantics.VarHandleArraySematics._ItemSemantics.__init__
__init__(self)
Definition
AtlasSemantics.py:47
python.AtlasSemantics.VarHandleArraySematics._ItemSemantics.store
store(self, value)
Definition
AtlasSemantics.py:50
python.AtlasSemantics.VarHandleArraySematics
Definition
AtlasSemantics.py:38
python.AtlasSemantics.VarHandleArraySematics._type
_type
Definition
AtlasSemantics.py:66
python.AtlasSemantics.VarHandleArraySematics._mode
str _mode
Definition
AtlasSemantics.py:70
python.AtlasSemantics.VarHandleArraySematics.__init__
__init__(self, cpp_type)
Definition
AtlasSemantics.py:59
python.AtlasSemantics.VarHandleArraySematics._isCond
str _isCond
Definition
AtlasSemantics.py:67
python.AtlasSemantics.VarHandleKeySemantics
Definition
AtlasSemantics.py:8
python.AtlasSemantics.VarHandleKeySemantics.store
store(self, value)
Definition
AtlasSemantics.py:27
python.AtlasSemantics.VarHandleKeySemantics._isCond
str _isCond
Definition
AtlasSemantics.py:18
python.AtlasSemantics.VarHandleKeySemantics.__init__
__init__(self, cpp_type)
Definition
AtlasSemantics.py:14
python.AtlasSemantics.VarHandleKeySemantics._type
_type
Definition
AtlasSemantics.py:17
python.AtlasSemantics.VarHandleKeySemantics._mode
str _mode
Definition
AtlasSemantics.py:21
GaudiConfig2.semantics
merge
Definition
merge.py:1
Generated on
for ATLAS Offline Software by
1.17.0