ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
StoreGate
src
WriteDecorHandleKey.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
3
*/
11
12
13
#include "
StoreGate/WriteDecorHandleKey.h
"
14
#include "GaudiKernel/IAlgTool.h"
15
#include "GaudiKernel/IDataHandleHolder.h"
16
#include "GaudiKernel/Algorithm.h"
17
18
19
namespace
SG
{
20
namespace
detail
{
21
22
29
bool
handleInHolder
(
const
DataObjID& contHandleKey,
30
const
IDataHandleHolder& holder)
31
{
32
for
(
const
Gaudi::DataHandle*
h
: holder.inputHandles()) {
33
if
(
h
->fullKey() == contHandleKey) {
34
return
true
;
35
}
36
}
37
38
for
(
const
Gaudi::DataHandle*
h
: holder.outputHandles()) {
39
if
(
h
->fullKey() == contHandleKey) {
40
return
true
;
41
}
42
}
43
44
return
false
;
45
}
46
47
57
const
IDataHandleHolder*
findParent
(
const
IDataHandleHolder*
h
)
58
{
59
while
(
true
) {
60
const
IAlgTool* astool =
dynamic_cast<
const
IAlgTool*
>
(
h
);
61
if
(!astool)
return
h
;
62
const
IInterface* parent = astool->parent();
63
if
(!parent)
return
h
;
64
auto
pdh =
dynamic_cast<
const
IDataHandleHolder*
>
(parent);
65
if
(!pdh)
return
h
;
66
if
(
dynamic_cast<
const
Gaudi::Algorithm*
>
(parent))
return
pdh;
67
h
= pdh;
68
}
69
}
70
71
80
class
WDHScan
81
:
public
IDataHandleVisitor
82
{
83
public
:
89
WDHScan
(
const
DataObjID& contHandleKey,
const
IDataHandleHolder* owner)
90
: m_contHandleKey (contHandleKey),
91
m_owner (owner)
92
{
93
}
94
96
virtual
void
visit (
const
IDataHandleHolder*
h
)
override
;
97
99
const
DataObjID& m_contHandleKey;
100
102
const
IDataHandleHolder* m_owner;
103
105
bool
m_found =
false
;
106
108
bool
m_sawOwner =
false
;
109
};
110
111
116
void
WDHScan::visit (
const
IDataHandleHolder*
h
)
117
{
118
// Don't do anything if we've already found the key, or if we've seen m_owner.
119
if
(m_found || m_sawOwner)
return
;
120
if
(
h
== m_owner) {
121
m_sawOwner =
true
;
122
return
;
123
}
124
125
// Test to see if this component has a key matching the one we're looking for.
126
m_found =
handleInHolder
(m_contHandleKey, *
h
);
127
}
128
129
153
void
registerWriteDecorHandleKey
(IDataHandleHolder* owner,
154
const
DataObjID& contHandleKey)
155
{
156
if
(!owner)
return
;
157
158
// Does this component already have a key matching @c contHandleKey?
159
bool
found =
handleInHolder
(contHandleKey, *owner);
160
161
if
(!found) {
162
// No --- now search the complete component tree up to @c owner for a match.
163
const
IDataHandleHolder* parent =
findParent
(owner);
164
if
(parent && parent != owner) {
165
WDHScan
scan
(contHandleKey, owner);
166
parent->acceptDHVisitor (&
scan
);
167
found =
scan
.m_found;
168
}
169
}
170
171
if
(!found) {
172
owner->addDependency (contHandleKey, Gaudi::DataHandle::Reader);
173
}
174
}
175
176
177
}
// namespace detail
178
}
// namespace SG
WriteDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
h
Header file for AthHistogramAlgorithm.
SG::detail::WDHScan
Helper to scan a tree of components to search for another handle key potentially conflicting with the...
Definition
WriteDecorHandleKey.cxx:82
scan
void scan(TDirectory *td=0, int depth=0)
Definition
listroot.cxx:440
SG::detail
Definition
DataVectorWithAllocFwd.h:22
SG::detail::registerWriteDecorHandleKey
void registerWriteDecorHandleKey(IDataHandleHolder *owner, const DataObjID &contHandleKey)
Optionally register read dependency of a WriteDecorHandleKey.
Definition
WriteDecorHandleKey.cxx:153
SG::detail::findParent
const IDataHandleHolder * findParent(const IDataHandleHolder *h)
Find the top-level Gaudi component for H.
Definition
WriteDecorHandleKey.cxx:57
SG::detail::handleInHolder
bool handleInHolder(const DataObjID &contHandleKey, const IDataHandleHolder &holder)
Test to see if HOLDER has registered a handle key matching CONTHANDLEKEY, as either input or output.
Definition
WriteDecorHandleKey.cxx:29
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
Generated on
for ATLAS Offline Software by
1.17.0