ATLAS Offline Software
SGIterator.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 */
5 /*
6  */
13 #ifndef STOREGATE_SGITERATOR_H
14 #define STOREGATE_SGITERATOR_H
15 
16 
17 #include "StoreGate/exceptions.h"
18 #include "SGTools/DataProxy.h"
19 #include "SGTools/DataProxy_cast.h"
20 #include "SGTools/ProxyMap.h"
22 #include <boost/iterator/iterator_facade.hpp>
23 class SGImplSvc;
24 
25 
26 namespace SG {
27 
28 
29 namespace detail {
30 
31 
37 class IteratorBase {
38 protected:
39  // Required for boost iterator adapter.
41 
42  // To access setState.
43  friend class ::SGImplSvc;
44 
45 
49  IteratorBase();
50 
51 
62  bool isConst);
63 
64 
69 
70 
74  ~IteratorBase();
75 
76 
81 
82 
94  bool isConst);
95 
96 
102  void increment();
103 
104 
108  bool eql(const IteratorBase& rhs) const;
109 
110 
116  void const_check() const;
117 
118 
119 public:
123  DataProxy* proxy() const;
124 
125 
129  const std::string& key() const;
130 
131 
132 private:
136  void addRef();
137 
138 
142  void release();
143 
144 
146  std::vector<SG::DataProxy*> m_proxies;
147 };
148 
149 
150 } //end ns detail
151 
152 
157 template <class DATA>
159  : public detail::IteratorBase,
160  public boost::iterator_facade<
161  ConstIterator<DATA>,
162  const DATA,
163  boost::forward_traversal_tag >
164 {
165 public:
170 
171 
179  explicit ConstIterator (const SG::ConstProxyIterator& itr,
180  const SG::ConstProxyIterator& itrEnd);
181 
182 
192  const SG::ConstProxyIterator& itrEnd);
193 
194 
195 private:
196  // Required for boost iterator adapter.
198  // INHERITED: void increment();
199 
200 
206  bool equal (const ConstIterator& rhs) const;
207 
208 
216  const DATA& dereference() const;
217 };
218 
219 
223 template <class DATA>
224 class Iterator
225  : public detail::IteratorBase,
226  public boost::iterator_facade<
227  Iterator<DATA>,
228  DATA,
229  boost::forward_traversal_tag >
230 {
231 public:
236 
237 
245  explicit Iterator (const SG::ConstProxyIterator& itr,
246  const SG::ConstProxyIterator& itrEnd);
247 
248 
258  const SG::ConstProxyIterator& itrEnd);
259 
260 
261 private:
262  // Required for boost iterator adapter.
264  //INHERITED: void increment();
265 
266 
272  bool equal(const Iterator<DATA>& rhs) const;
273 
274 
283  DATA& dereference() const;
284 };
285 
286 
287 } // namespace SG
288 
289 
290 #include "StoreGate/SGIterator.icc"
291 
292 
293 #endif
294 
SG::detail::IteratorBase::proxy
DataProxy * proxy() const
The proxy pointed at by this iterator.
SG::ConstIterator::setState
StatusCode setState(const SG::ConstProxyIterator &itr, const SG::ConstProxyIterator &itrEnd)
Reset state of the iterator.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
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::Iterator::iterator_core_access
friend class boost::iterator_core_access
Definition: SGIterator.h:263
detail
Definition: extract_histogram_tag.cxx:14
SG::ConstIterator::dereference
const DATA & dereference() const
Dereference the iterator.
SG::detail::IteratorBase::setState
StatusCode setState(SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
Reset state of the iterator.
Definition: SGIterator.cxx:94
ProxyMap.h
SG::Iterator::dereference
DATA & dereference() const
Dereference the iterator.
SG::detail::IteratorBase::operator=
IteratorBase & operator=(const IteratorBase &other)
Assignment.
Definition: SGIterator.cxx:72
SG::Iterator
Definition: SGIterator.h:230
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::increment
void increment()
Move to the next valid proxy.
Definition: SGIterator.cxx:123
SG::detail::IteratorBase::~IteratorBase
~IteratorBase()
Destructor.
Definition: SGIterator.cxx:61
exceptions.h
Exceptions that can be thrown from StoreGate.
SG::Iterator::Iterator
Iterator()
Default constructor.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::Iterator::Iterator
Iterator(const SG::ConstProxyIterator &itr, const SG::ConstProxyIterator &itrEnd)
Constructor from proxy iterator pair.
SG::detail::IteratorBase::IteratorBase
IteratorBase()
Default constructor.
Definition: SGIterator.cxx:18
SGImplSvc
The Athena Transient Store API.
Definition: SGImplSvc.h:112
SG::ConstIterator::ConstIterator
ConstIterator(const SG::ConstProxyIterator &itr, const SG::ConstProxyIterator &itrEnd)
Constructor from proxy iterator pair.
SGIterator.icc
IProxyDict.h
SG::detail::IteratorBase::eql
bool eql(const IteratorBase &rhs) const
Equality check.
SG::ConstIterator::ConstIterator
ConstIterator()
Default constructor.
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
DataProxy_cast.h
Helpers for retrieving the payload held by a DataProxy.
SG::ConstIterator::equal
bool equal(const ConstIterator &rhs) const
Equality check.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::Iterator::setState
StatusCode setState(const SG::ConstProxyIterator &itr, const SG::ConstProxyIterator &itrEnd)
Reset state of the iterator.
SG::detail::IteratorBase
Definition: SGIterator.h:37
SG::Iterator::equal
bool equal(const Iterator< DATA > &rhs) const
Equality check.
SG::detail::IteratorBase::release
void release()
Remove a reference count from all proxies in our range.
SG::ConstIterator::iterator_core_access
friend class boost::iterator_core_access
Definition: SGIterator.h:197
SG::DataProxy
Definition: DataProxy.h:45
SG::detail::IteratorBase::iterator_core_access
friend class boost::iterator_core_access
Definition: SGIterator.h:40
SG::ConstIterator
Definition: SGIterator.h:164
SG::ConstProxyIterator
ProxyMap::const_iterator ConstProxyIterator
Definition: ProxyMap.h:28
SG::detail::IteratorBase::addRef
void addRef()
Add a reference count to all proxies in our range.
DataProxy.h