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-2018 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/ProxyMap.h"
21 #include <boost/iterator/iterator_facade.hpp>
22 class SGImplSvc;
23 
24 
25 namespace SG {
26 
27 
28 namespace detail {
29 
30 
36 class IteratorBase {
37 protected:
38  // Required for boost iterator adapter.
40 
41  // To access setState.
42  friend class ::SGImplSvc;
43 
44 
48  IteratorBase();
49 
50 
61  bool isConst);
62 
63 
68 
69 
73  ~IteratorBase();
74 
75 
80 
81 
93  bool isConst);
94 
95 
101  void increment();
102 
103 
107  bool eql(const IteratorBase& rhs) const;
108 
109 
115  void const_check() const;
116 
117 
118 public:
122  DataProxy* proxy() const;
123 
124 
128  const std::string& key() const;
129 
130 
131 private:
135  void addRef();
136 
137 
141  void release();
142 
143 
145  std::vector<SG::DataProxy*> m_proxies;
146 };
147 
148 
149 } //end ns detail
150 
151 
156 template <class DATA>
158  : public detail::IteratorBase,
159  public boost::iterator_facade<
160  ConstIterator<DATA>,
161  const DATA,
162  boost::forward_traversal_tag >
163 {
164 public:
169 
170 
178  explicit ConstIterator (const SG::ConstProxyIterator& itr,
179  const SG::ConstProxyIterator& itrEnd);
180 
181 
191  const SG::ConstProxyIterator& itrEnd);
192 
193 
194 private:
195  // Required for boost iterator adapter.
197  // INHERITED: void increment();
198 
199 
205  bool equal (const ConstIterator& rhs) const;
206 
207 
215  const DATA& dereference() const;
216 };
217 
218 
222 template <class DATA>
223 class Iterator
224  : public detail::IteratorBase,
225  public boost::iterator_facade<
226  Iterator<DATA>,
227  DATA,
228  boost::forward_traversal_tag >
229 {
230 public:
235 
236 
244  explicit Iterator (const SG::ConstProxyIterator& itr,
245  const SG::ConstProxyIterator& itrEnd);
246 
247 
257  const SG::ConstProxyIterator& itrEnd);
258 
259 
260 private:
261  // Required for boost iterator adapter.
263  //INHERITED: void increment();
264 
265 
271  bool equal(const Iterator<DATA>& rhs) const;
272 
273 
282  DATA& dereference() const;
283 };
284 
285 
286 } // namespace SG
287 
288 
289 #include "StoreGate/SGIterator.icc"
290 
291 
292 #endif
293 
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:262
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:229
SG::detail::IteratorBase::m_proxies
std::vector< SG::DataProxy * > m_proxies
All proxies in our range, in reverse order.
Definition: SGIterator.h:145
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
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:36
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:196
SG::DataProxy
Definition: DataProxy.h:45
SG::detail::IteratorBase::iterator_core_access
friend class boost::iterator_core_access
Definition: SGIterator.h:39
SG::ConstIterator
Definition: SGIterator.h:163
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