ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
DataQualityInterfaces
src
MiniConfigTreeNode.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// **********************************************************************
6
// **********************************************************************
7
8
#include <utility>
9
10
#include "
DataQualityInterfaces/MiniConfigTreeNode.h
"
11
12
13
//Get rid of Root macros that confuse Doxygen
15
ClassImp
(
dqi::MiniConfigTreeNode
)
17
18
19
namespace
dqi
{
20
21
// *********************************************************************
22
// Public Methods
23
// *********************************************************************
24
25
MiniConfigTreeNode::
26
MiniConfigTreeNode
( std::string name_,
MiniConfigTreeNode
* parent_ )
27
:
m_name
(
std
::move(name_))
28
,
m_parent
(parent_)
29
,
m_propagateDown
(true)
30
{
31
}
32
33
34
MiniConfigTreeNode::
35
~MiniConfigTreeNode
()
36
{
37
NodeIter_t
daugEnd =
m_daughters
.end();
38
for
(
NodeIter_t
i =
m_daughters
.begin(); i != daugEnd; ++i ) {
39
MiniConfigTreeNode
*
inode
= i->second;
40
delete
inode
;
41
}
42
}
43
44
45
const
char
*
46
MiniConfigTreeNode::
47
GetName
()
const
48
{
49
return
m_name
.c_str();
50
}
51
52
53
std::string
54
MiniConfigTreeNode::
55
GetPathName
()
const
56
{
57
std::string path;
58
if
(
m_parent
!= 0 ) {
59
std::string parentPath(
m_parent
->GetPathName() );
60
if
( !parentPath.empty() ) {
61
path += parentPath;
62
path += std::string(
"/"
);
63
}
64
path +=
m_name
;
65
}
66
return
path;
67
}
68
69
70
MiniConfigTreeNode
*
71
MiniConfigTreeNode::
72
GetNewDaughter
( std::string name_ )
73
{
74
NodeIter_t
i =
m_daughters
.find( name_ );
75
if
( i !=
m_daughters
.end() ) {
76
return
i->second;
77
}
78
79
MiniConfigTreeNode
*
node
=
new
MiniConfigTreeNode
( name_,
this
);
80
node
->SetAttribKeywordPropagateDown(this->
m_propagateDown
);
81
NodeMap_t::value_type nodeVal( name_,
node
);
82
m_daughters
.insert( std::move(nodeVal) );
83
return
node
;
84
}
85
86
87
MiniConfigTreeNode
*
88
MiniConfigTreeNode::
89
GetDaughter
( std::string name_ )
const
90
{
91
NodeIter_t
i =
m_daughters
.find( name_ );
92
if
( i !=
m_daughters
.end() ) {
93
return
i->second;
94
}
95
return
0;
96
}
97
98
99
std::map<std::string,MiniConfigTreeNode*>
100
MiniConfigTreeNode::
101
GetDaughters
()
const
102
{
103
return
m_daughters
;
104
}
105
106
const
MiniConfigTreeNode
*
107
MiniConfigTreeNode::
108
GetNode
(
const
std::string & name_ )
const
109
{
110
if
(
m_daughters
.size() == 0 ) {
111
return
this
;
112
}
113
114
std::string::size_type k = name_.find_first_of(
'/'
);
115
if
( k != std::string::npos ) {
116
std::string dName( name_, 0, k );
117
std::string pName( name_, k+1, std::string::npos );
118
if
( dName !=
""
) {
119
NodeIter_t
i =
m_daughters
.find( dName );
120
if
( i ==
m_daughters
.end() ) {
121
return
this
;
122
}
123
MiniConfigTreeNode
*
node
= i->second;
124
return
node
->GetNode( pName );
125
}
126
return
GetNode
( pName );
127
}
128
129
NodeIter_t
i =
m_daughters
.find( name_ );
130
if
( i ==
m_daughters
.end() ) {
131
return
this
;
132
}
133
return
i->second;
134
}
135
136
137
void
138
MiniConfigTreeNode::
139
SetAttribute
(
const
std::string & attName,
const
std::string & attValue,
bool
isAttribKeyword )
140
{
141
AttMap_t::value_type attMapVal( attName, AttMap_t::mapped_type(attValue, isAttribKeyword) );
142
m_attributes
.insert( std::move(attMapVal) );
143
}
144
145
146
std::string
147
MiniConfigTreeNode::
148
GetAttribute
( std::string_view attName,
bool
calledFromDaughter )
const
149
{
150
AttIter_t
i =
m_attributes
.find( attName );
151
if
( i ==
m_attributes
.end() ) {
152
if
(
m_parent
!= 0 )
153
return
m_parent
->GetAttribute( attName,
true
);
154
else
155
return
std::string(
""
);
156
}
157
if
(calledFromDaughter && !
m_propagateDown
&& i->second.second) {
158
return
std::string(
""
);
159
}
160
return
i->second.first;
161
}
162
163
// Like GetAttributes, but only returns attributes of *this* node,
164
// not inherited ones
165
std::string
166
MiniConfigTreeNode::
167
GetAttributeLocal
(
const
std::string & attName )
const
168
{
169
AttIter_t
i =
m_attributes
.find( attName );
170
if
( i ==
m_attributes
.end() ) {
171
return
std::string(
""
);
172
}
173
return
i->second.first;
174
}
175
176
177
void
178
MiniConfigTreeNode::
179
GetAttributeNames
( std::set<std::string>& attSet,
bool
calledFromDaughter )
const
180
{
181
if
(
m_parent
!=0 ) {
182
m_parent
->GetAttributeNames( attSet,
true
);
183
}
184
AttIter_t
attEnd =
m_attributes
.end();
185
for
(
AttIter_t
i =
m_attributes
.begin(); i != attEnd; ++i ) {
186
if
(calledFromDaughter && !
m_propagateDown
&& i->second.second) {
187
}
else
{
188
std::set<std::string>::value_type setVal( i->first );
189
attSet.insert( std::move(setVal) );
190
}
191
}
192
}
193
194
// Like GetAttributeNames, but only returns attributes of this node
195
void
196
MiniConfigTreeNode::
197
GetAttributeNamesLocal
( std::set<std::string>& attSet )
const
198
{
199
AttIter_t
attEnd =
m_attributes
.end();
200
for
(
AttIter_t
i =
m_attributes
.begin(); i != attEnd; ++i ) {
201
std::set<std::string>::value_type setVal( i->first );
202
attSet.insert( std::move(setVal) );
203
}
204
}
205
206
void
207
MiniConfigTreeNode::
208
Accept
(
Visitor
& visitor )
const
209
{
210
visitor.
Visit
(
this
);
211
NodeIter_t
daugEnd =
m_daughters
.end();
212
for
(
NodeIter_t
i =
m_daughters
.begin(); i != daugEnd; ++i ) {
213
MiniConfigTreeNode
*
node
= i->second;
214
node
->Accept(visitor);
215
}
216
}
217
218
void
219
MiniConfigTreeNode::
220
Accept
(
Writer
&
writer
)
221
{
222
writer
.Write(
this
);
223
NodeIter_t
daugEnd =
m_daughters
.end();
224
for
(
NodeIter_t
i =
m_daughters
.begin(); i != daugEnd; ++i ) {
225
MiniConfigTreeNode
*
node
= i->second;
226
node
->Accept(
writer
);
227
}
228
}
229
230
void
231
MiniConfigTreeNode::
232
SetAttribKeywordPropagateDown
(
bool
propagateDown )
233
{
234
this->
m_propagateDown
= propagateDown;
235
}
236
237
bool
238
MiniConfigTreeNode::
239
GetAttribKeywordPropagateDown
()
const
240
{
241
return
this->
m_propagateDown
;
242
}
243
244
}
// namespace dqi
writer
std::shared_ptr< HepMC3::Writer > writer
MiniConfigTreeNode.h
ClassImp
ClassImp(xAOD::Experimental::RFileChecker) namespace xAOD
Definition
RFileChecker.cxx:28
dqi::MiniConfigTreeNode::Visitor
Definition
MiniConfigTreeNode.h:29
dqi::MiniConfigTreeNode::Visitor::Visit
virtual void Visit(const MiniConfigTreeNode *node)=0
dqi::MiniConfigTreeNode::Writer
Definition
MiniConfigTreeNode.h:35
dqi::MiniConfigTreeNode
A node of a tree structure holding a configuration, where each node may be given attributes,...
Definition
MiniConfigTreeNode.h:26
dqi::MiniConfigTreeNode::m_parent
MiniConfigTreeNode * m_parent
Definition
MiniConfigTreeNode.h:102
dqi::MiniConfigTreeNode::GetAttributeLocal
virtual std::string GetAttributeLocal(const std::string &attName) const
Definition
MiniConfigTreeNode.cxx:167
dqi::MiniConfigTreeNode::MiniConfigTreeNode
MiniConfigTreeNode(std::string name_, MiniConfigTreeNode *parent_)
Definition
MiniConfigTreeNode.cxx:26
dqi::MiniConfigTreeNode::GetNode
virtual const MiniConfigTreeNode * GetNode(const std::string &name_) const
This function takes the full path name of a subnode (in UNIX directory style) and returns the corresp...
Definition
MiniConfigTreeNode.cxx:108
dqi::MiniConfigTreeNode::GetAttribKeywordPropagateDown
virtual bool GetAttribKeywordPropagateDown() const
Definition
MiniConfigTreeNode.cxx:239
dqi::MiniConfigTreeNode::GetDaughter
virtual MiniConfigTreeNode * GetDaughter(std::string name_) const
Definition
MiniConfigTreeNode.cxx:89
dqi::MiniConfigTreeNode::GetName
virtual const char * GetName() const
Definition
MiniConfigTreeNode.cxx:47
dqi::MiniConfigTreeNode::GetDaughters
virtual std::map< std::string, dqi::MiniConfigTreeNode * > GetDaughters() const
Definition
MiniConfigTreeNode.cxx:101
dqi::MiniConfigTreeNode::Accept
virtual void Accept(Visitor &visitor) const
Definition
MiniConfigTreeNode.cxx:208
dqi::MiniConfigTreeNode::GetNewDaughter
virtual MiniConfigTreeNode * GetNewDaughter(std::string name_)
Returns a daughter of this node, creating one if necessary.
Definition
MiniConfigTreeNode.cxx:72
dqi::MiniConfigTreeNode::AttIter_t
AttMap_t::const_iterator AttIter_t
Definition
MiniConfigTreeNode.h:99
dqi::MiniConfigTreeNode::GetAttributeNames
virtual void GetAttributeNames(std::set< std::string > &attSet, bool calledFromDaughter=false) const
Definition
MiniConfigTreeNode.cxx:179
dqi::MiniConfigTreeNode::SetAttribute
virtual void SetAttribute(const std::string &attName, const std::string &attValue, bool isAttribKeyword=false)
Definition
MiniConfigTreeNode.cxx:139
dqi::MiniConfigTreeNode::SetAttribKeywordPropagateDown
virtual void SetAttribKeywordPropagateDown(bool propagateDown)
Definition
MiniConfigTreeNode.cxx:232
dqi::MiniConfigTreeNode::m_name
const std::string m_name
Definition
MiniConfigTreeNode.h:101
dqi::MiniConfigTreeNode::GetPathName
virtual std::string GetPathName() const
Definition
MiniConfigTreeNode.cxx:55
dqi::MiniConfigTreeNode::GetAttributeNamesLocal
virtual void GetAttributeNamesLocal(std::set< std::string > &attSet) const
Definition
MiniConfigTreeNode.cxx:197
dqi::MiniConfigTreeNode::NodeIter_t
NodeMap_t::const_iterator NodeIter_t
Definition
MiniConfigTreeNode.h:96
dqi::MiniConfigTreeNode::m_attributes
AttMap_t m_attributes
Definition
MiniConfigTreeNode.h:105
dqi::MiniConfigTreeNode::GetAttribute
virtual std::string GetAttribute(std::string_view attName, bool calledFromDaughter=false) const
Definition
MiniConfigTreeNode.cxx:148
dqi::MiniConfigTreeNode::m_daughters
NodeMap_t m_daughters
Definition
MiniConfigTreeNode.h:104
dqi::MiniConfigTreeNode::~MiniConfigTreeNode
virtual ~MiniConfigTreeNode()
Definition
MiniConfigTreeNode.cxx:35
dqi::MiniConfigTreeNode::m_propagateDown
bool m_propagateDown
Definition
MiniConfigTreeNode.h:107
inode
Definition
listroot.cxx:155
node
Definition
node.h:24
dqi
Definition
CompositeAlgorithm.h:16
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0