ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14
21
22
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
51 : m_proxies (other.m_proxies)
52{
53 // Maintain shared ownership of elements in our range.
54 this->addRef();
55}
56
57
62{
63 // Release ownership of everything in our range.
64 this->release();
65}
66
67
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
93StatusCode
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
124{
125 if (!m_proxies.empty()) {
126 m_proxies.back()->release();
127 m_proxies.pop_back();
128 }
129}
130
131
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
155const std::string& SG::detail::IteratorBase::key() const
156{
157 return m_proxies.back()->name();
158}
A standard conforming forward iterator over items in StoreGate.
virtual const std::string & name() const override
Definition TestStore.cxx:97
Exception — Tried to retrieve non-const pointer to const object.
Implementation class, not to be used directly Iterates over valid proxies it the range.
Definition SGIterator.h:37
std::vector< SG::DataProxy * > m_proxies
All proxies in our range, in reverse order.
Definition SGIterator.h:146
const std::string & key() const
Get the key string with which the current object was stored.
DataProxy * proxy() const
The proxy pointed at by this iterator.
void increment()
Move to the next valid proxy.
IteratorBase & operator=(const IteratorBase &other)
Assignment.
void const_check() const
Const check: throw an exception if we're pointing at a const proxy.
IteratorBase()
Default constructor.
StatusCode setState(SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
Reset state of the iterator.
void addRef()
Add a reference count to all proxies in our range.
static std::string release
Definition computils.h:50
ProxyMap::const_iterator ConstProxyIterator
Definition ProxyMap.h:24