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-2018 CERN for the benefit of the ATLAS collaboration
3
*/
4
/*
5
*/
10
11
12
#include "
StoreGate/SGIterator.h
"
13
14
18
SG::detail::IteratorBase::IteratorBase
()
19
{
20
}
21
22
31
SG::detail::IteratorBase::IteratorBase
(
SG::ConstProxyIterator
itr,
32
SG::ConstProxyIterator
itrEnd,
33
bool
isConst)
34
{
35
// Save all valid proxies in reverse order. Also take out a refcount on each.
36
while
(itr != itrEnd) {
37
--itrEnd;
38
DataProxy
* dp = itrEnd->second;
39
if
(dp->isValid() && (isConst || !dp->isConst())) {
40
m_proxies
.push_back (dp);
41
dp->addRef();
42
}
43
}
44
}
45
46
50
SG::detail::IteratorBase::IteratorBase
(
const
IteratorBase
& other)
51
:
m_proxies
(other.
m_proxies
)
52
{
53
// Maintain shared ownership of elements in our range.
54
this->
addRef
();
55
}
56
57
61
SG::detail::IteratorBase::~IteratorBase
()
62
{
63
// Release ownership of everything in our range.
64
this->
release
();
65
}
66
67
71
SG::detail::IteratorBase
&
72
SG::detail::IteratorBase::operator=
(
const
IteratorBase
& other)
73
{
74
if
(
this
!= &other) {
75
// Assign, maintaining refcounts.
76
this->
release
();
77
m_proxies
= other.m_proxies;
78
this->
addRef
();
79
}
80
return
*
this
;
81
}
82
83
93
StatusCode
94
SG::detail::IteratorBase::setState
(
SG::ConstProxyIterator
itr,
95
SG::ConstProxyIterator
itrEnd,
96
bool
isConst)
97
{
98
this->
release
();
99
m_proxies
.clear();
100
101
while
(itr != itrEnd) {
102
--itrEnd;
103
DataProxy
* dp = itrEnd->second;
104
if
(dp->isValid() && (isConst || !dp->isConst())) {
105
m_proxies
.push_back (dp);
106
dp->addRef();
107
}
108
}
109
110
if
(
m_proxies
.empty()) {
111
return
StatusCode::FAILURE;
112
}
113
114
return
StatusCode::SUCCESS;
115
}
116
117
123
void
SG::detail::IteratorBase::increment
()
124
{
125
if
(!
m_proxies
.empty()) {
126
m_proxies
.back()->release();
127
m_proxies
.pop_back();
128
}
129
}
130
131
137
void
SG::detail::IteratorBase::const_check
()
const
138
{
139
// This should usually not be needed, since we check for constness
140
// when initializing the iterator. However, it is possible for a proxy
141
// to be marked as const after the iterator has been formed, so keep the check.
142
const
SG::DataProxy
* dp = this->
proxy
();
143
if
(dp->isConst()) {
144
const
IProxyDict
* store = dp->store();
145
throw
SG::ExcConstObject
(dp->clID(),
146
dp->name(),
147
store ? store->
name
() :
"(unknown)"
);
148
}
149
}
150
151
155
const
std::string&
SG::detail::IteratorBase::key
()
const
156
{
157
return
m_proxies
.back()->name();
158
}
SGIterator.h
A standard conforming forward iterator over items in StoreGate.
IProxyDict
A proxy dictionary.
Definition
AthenaKernel/AthenaKernel/IProxyDict.h:47
SGTest::TestStore::name
virtual const std::string & name() const override
Definition
TestStore.cxx:97
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 it the range.
Definition
SGIterator.h:37
SG::detail::IteratorBase::m_proxies
std::vector< SG::DataProxy * > m_proxies
All proxies in our range, in reverse order.
Definition
SGIterator.h:146
SG::detail::IteratorBase::key
const std::string & key() const
Get the key string with which the current object was stored.
Definition
SGIterator.cxx:155
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:123
SG::detail::IteratorBase::~IteratorBase
~IteratorBase()
Destructor.
Definition
SGIterator.cxx:61
SG::detail::IteratorBase::operator=
IteratorBase & operator=(const IteratorBase &other)
Assignment.
Definition
SGIterator.cxx:72
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:137
SG::detail::IteratorBase::IteratorBase
IteratorBase()
Default constructor.
Definition
SGIterator.cxx:18
SG::detail::IteratorBase::setState
StatusCode setState(SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
Reset state of the iterator.
Definition
SGIterator.cxx:94
SG::detail::IteratorBase::addRef
void addRef()
Add a reference count to all proxies in our range.
release
static std::string release
Definition
computils.h:50
SG::ConstProxyIterator
ProxyMap::const_iterator ConstProxyIterator
Definition
ProxyMap.h:24
Generated on
for ATLAS Offline Software by
1.17.0