ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SG::ConstIterator< DATA > Class Template Reference

#include <SGIterator.h>

Inheritance diagram for SG::ConstIterator< DATA >:
Collaboration diagram for SG::ConstIterator< DATA >:

Public Member Functions

 ConstIterator ()
 Default constructor. More...
 
 ConstIterator (const SG::ConstProxyIterator &itr, const SG::ConstProxyIterator &itrEnd)
 Constructor from proxy iterator pair. More...
 
StatusCode setState (const SG::ConstProxyIterator &itr, const SG::ConstProxyIterator &itrEnd)
 Reset state of the iterator. More...
 
DataProxyproxy () const
 The proxy pointed at by this iterator. More...
 
const std::string & key () const
 Get the key string with which the current object was stored. More...
 

Protected Member Functions

StatusCode setState (SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
 Reset state of the iterator. More...
 
void increment ()
 Move to the next valid proxy. More...
 
bool eql (const IteratorBase &rhs) const
 Equality check. More...
 
void const_check () const
 Const check: throw an exception if we're pointing at a const proxy. More...
 

Private Member Functions

bool equal (const ConstIterator &rhs) const
 Equality check. More...
 
const DATA & dereference () const
 Dereference the iterator. More...
 
void addRef ()
 Add a reference count to all proxies in our range. More...
 
void release ()
 Remove a reference count from all proxies in our range. More...
 

Private Attributes

std::vector< SG::DataProxy * > m_proxies
 All proxies in our range, in reverse order. More...
 

Friends

class boost::iterator_core_access
 

Detailed Description

template<class DATA>
class SG::ConstIterator< DATA >

a const_iterator facade to DataHandle. Behaves like a forward iterator

Definition at line 157 of file SGIterator.h.

Constructor & Destructor Documentation

◆ ConstIterator() [1/2]

template<class DATA >
SG::ConstIterator< DATA >::ConstIterator ( )

Default constructor.

◆ ConstIterator() [2/2]

template<class DATA >
SG::ConstIterator< DATA >::ConstIterator ( const SG::ConstProxyIterator itr,
const SG::ConstProxyIterator itrEnd 
)
explicit

Constructor from proxy iterator pair.

Parameters
itrStarting proxy iterator.
itrEndEnding proxy iterator.

Will skip ahead to the first valid proxy.

Member Function Documentation

◆ addRef()

void SG::detail::IteratorBase::addRef ( )
privateinherited

Add a reference count to all proxies in our range.

◆ const_check()

void SG::detail::IteratorBase::const_check ( ) const
protectedinherited

Const check: throw an exception if we're pointing at a const proxy.

Called when dereferencing a non-const iterator.

Definition at line 137 of file SGIterator.cxx.

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 }

◆ dereference()

template<class DATA >
const DATA& SG::ConstIterator< DATA >::dereference ( ) const
private

Dereference the iterator.

Used by the boost iterator adapter.

Will throw SG::ExcInvalidIterator() if the proxy is not valid.

◆ eql()

bool SG::detail::IteratorBase::eql ( const IteratorBase rhs) const
protectedinherited

Equality check.

◆ equal()

template<class DATA >
bool SG::ConstIterator< DATA >::equal ( const ConstIterator< DATA > &  rhs) const
private

Equality check.

Used by the boost iterator adapter.

◆ increment()

void SG::detail::IteratorBase::increment ( )
protectedinherited

Move to the next valid proxy.

Used by the boost iterator adapter.

Definition at line 123 of file SGIterator.cxx.

124 {
125  if (!m_proxies.empty()) {
126  m_proxies.back()->release();
127  m_proxies.pop_back();
128  }
129 }

◆ key()

const std::string & SG::detail::IteratorBase::key ( ) const
inherited

Get the key string with which the current object was stored.

Definition at line 155 of file SGIterator.cxx.

156 {
157  return m_proxies.back()->name();
158 }

◆ proxy()

DataProxy* SG::detail::IteratorBase::proxy ( ) const
inherited

The proxy pointed at by this iterator.

◆ release()

void SG::detail::IteratorBase::release ( )
privateinherited

Remove a reference count from all proxies in our range.

◆ setState() [1/2]

template<class DATA >
StatusCode SG::ConstIterator< DATA >::setState ( const SG::ConstProxyIterator itr,
const SG::ConstProxyIterator itrEnd 
)

Reset state of the iterator.

Parameters
itrStarting proxy iterator.
itrEndEnding proxy iterator.

Will skip ahead to the first valid proxy. Will return failure if the range is empty.

◆ setState() [2/2]

StatusCode SG::detail::IteratorBase::setState ( SG::ConstProxyIterator  itr,
SG::ConstProxyIterator  itrEnd,
bool  isConst 
)
protectedinherited

Reset state of the iterator.

Parameters
itrStarting proxy iterator.
itrEndEnding proxy iterator.
isConstIs this for a const iterator?

Will skip ahead to the first valid proxy. Returns FAILURE if the range is empty.

Definition at line 94 of file SGIterator.cxx.

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 }

Friends And Related Function Documentation

◆ boost::iterator_core_access

template<class DATA >
friend class boost::iterator_core_access
friend

Definition at line 196 of file SGIterator.h.

Member Data Documentation

◆ m_proxies

std::vector<SG::DataProxy*> SG::detail::IteratorBase::m_proxies
privateinherited

All proxies in our range, in reverse order.

Definition at line 145 of file SGIterator.h.


The documentation for this class was generated from the following file:
SG::detail::IteratorBase::proxy
DataProxy * proxy() const
The proxy pointed at by this iterator.
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
SG::DataProxy::isConst
bool isConst() const
Check if it is a const object.
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::detail::IteratorBase::m_proxies
std::vector< SG::DataProxy * > m_proxies
All proxies in our range, in reverse order.
Definition: SGIterator.h:145
DataProxy
DataProxy provides the registry services for StoreGate.
Definition: DataProxy.h:31
SG::ExcConstObject
Exception — Tried to retrieve non-const pointer to const object.
Definition: Control/StoreGate/StoreGate/exceptions.h:134
SG::detail::IteratorBase::release
void release()
Remove a reference count from all proxies in our range.
SG::DataProxy
Definition: DataProxy.h:44