ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
StoreGate
src
SGIterator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
/*
5
*/
10
11
12
#include "
StoreGate/SGIterator.h
"
13
14
23
SG::detail::IteratorBase::IteratorBase
(
SG::ConstProxyIterator
itr,
24
SG::ConstProxyIterator
itrEnd,
25
bool
isConst)
26
{
27
setState
(itr, itrEnd, isConst).ignore();
28
}
29
30
34
SG::detail::IteratorBase::IteratorBase
(
const
IteratorBase
& other)
35
:
m_proxies
(other.
m_proxies
)
36
{
37
// Maintain shared ownership of elements in our range.
38
this->
addRef
();
39
}
40
41
45
SG::detail::IteratorBase::~IteratorBase
()
46
{
47
// Release ownership of everything in our range.
48
this->
release
();
49
}
50
51
55
SG::detail::IteratorBase
&
56
SG::detail::IteratorBase::operator=
(
const
IteratorBase
& other)
57
{
58
if
(
this
!= &other) {
59
// Assign, maintaining refcounts.
60
this->
release
();
61
m_proxies
= other.m_proxies;
62
this->
addRef
();
63
}
64
return
*
this
;
65
}
66
67
77
StatusCode
78
SG::detail::IteratorBase::setState
(
SG::ConstProxyIterator
itr,
79
SG::ConstProxyIterator
itrEnd,
80
bool
isConst)
81
{
82
if
(!
m_proxies
.empty()) {
83
this->
release
();
84
m_proxies
.clear();
85
}
86
87
// Save all valid proxies in reverse order. Also take out a refcount on each.
88
while
(itr != itrEnd) {
89
--itrEnd;
90
DataProxy
* dp = itrEnd->second;
91
if
(dp->isValid() && (isConst || !dp->isConst())) {
92
m_proxies.push_back (dp);
93
dp->addRef();
94
}
95
}
96
97
if
(m_proxies.empty()) {
98
return
StatusCode::FAILURE;
99
}
100
101
return
StatusCode::SUCCESS;
102
}
103
104
110
void
SG::detail::IteratorBase::increment
()
111
{
112
if
(!
m_proxies
.empty()) {
113
m_proxies
.back()->release();
114
m_proxies
.pop_back();
115
}
116
}
117
118
124
void
SG::detail::IteratorBase::const_check
()
const
125
{
126
// This should usually not be needed, since we check for constness
127
// when initializing the iterator. However, it is possible for a proxy
128
// to be marked as const after the iterator has been formed, so keep the check.
129
const
SG::DataProxy
* dp = this->
proxy
();
130
if
(dp->isConst()) {
131
const
IProxyDict
* store = dp->store();
132
throw
SG::ExcConstObject
(dp->clID(),
133
dp->name(),
134
store ? store->
name
() :
"(unknown)"
);
135
}
136
}
137
138
142
const
std::string&
SG::detail::IteratorBase::key
()
const
143
{
144
return
m_proxies
.back()->name();
145
}
SGIterator.h
A standard conforming forward iterator over items in StoreGate.
IProxyDict
A proxy dictionary.
Definition
AthenaKernel/AthenaKernel/IProxyDict.h:48
SGTest::TestStore::name
virtual const std::string & name() const override
Definition
TestStore.cxx:109
SG::DataProxy
Definition
DataProxy.h:45
SG::ExcConstObject
Exception — Tried to retrieve non-const pointer to const object.
Definition
Control/StoreGate/StoreGate/exceptions.h:134
SG::detail::IteratorBase
Implementation class, not to be used directly Iterates over valid proxies in the range.
Definition
SGIterator.h:42
SG::detail::IteratorBase::m_proxies
std::vector< SG::DataProxy * > m_proxies
All proxies in our range, in reverse order.
Definition
SGIterator.h:176
SG::detail::IteratorBase::key
const std::string & key() const
Get the key string with which the current object was stored.
Definition
SGIterator.cxx:142
SG::detail::IteratorBase::proxy
DataProxy * proxy() const
The proxy pointed at by this iterator.
SG::detail::IteratorBase::increment
void increment()
Move to the next valid proxy.
Definition
SGIterator.cxx:110
SG::detail::IteratorBase::~IteratorBase
~IteratorBase()
Destructor.
Definition
SGIterator.cxx:45
SG::detail::IteratorBase::operator=
IteratorBase & operator=(const IteratorBase &other)
Assignment.
Definition
SGIterator.cxx:56
SG::detail::IteratorBase::const_check
void const_check() const
Const check: throw an exception if we're pointing at a const proxy.
Definition
SGIterator.cxx:124
SG::detail::IteratorBase::IteratorBase
IteratorBase()=default
Default constructor.
SG::detail::IteratorBase::setState
StatusCode setState(SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
Reset state of the iterator.
Definition
SGIterator.cxx:78
SG::detail::IteratorBase::addRef
void addRef()
Add a reference count to all proxies in our range.
release
static std::string release
Definition
computils.h:54
SG::ConstProxyIterator
ProxyMap::const_iterator ConstProxyIterator
Definition
ProxyMap.h:24
Generated on
for ATLAS Offline Software by
1.17.0