ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SG::detail::IteratorBase Class Reference

#include <SGIterator.h>

Inheritance diagram for SG::detail::IteratorBase:
Collaboration diagram for SG::detail::IteratorBase:

Public Member Functions

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

 IteratorBase ()
 Default constructor. More...
 
 IteratorBase (SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
 Constructor from proxy iterator pair. More...
 
 IteratorBase (const IteratorBase &other)
 Copy constructor. More...
 
 ~IteratorBase ()
 Destructor. More...
 
IteratorBaseoperator= (const IteratorBase &other)
 Assignment. More...
 
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

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
 
class ::SGImplSvc
 

Detailed Description

Implementation class, not to be used directly Iterates over valid proxies it the range. Maintains a reference count on proxies within the range.

Definition at line 36 of file SGIterator.h.

Constructor & Destructor Documentation

◆ IteratorBase() [1/3]

SG::detail::IteratorBase::IteratorBase ( )
protected

Default constructor.

Definition at line 18 of file SGIterator.cxx.

19 {
20 }

◆ IteratorBase() [2/3]

SG::detail::IteratorBase::IteratorBase ( SG::ConstProxyIterator  itr,
SG::ConstProxyIterator  itrEnd,
bool  isConst 
)
explicitprotected

Constructor from proxy iterator pair.

Parameters
itrStarting proxy iterator.
itrEndEnding proxy iterator.
isConstIf false, take only non-const proxies.

Will skip ahead to the first valid proxy.

Definition at line 31 of file SGIterator.cxx.

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 }

◆ IteratorBase() [3/3]

SG::detail::IteratorBase::IteratorBase ( const IteratorBase other)
protected

Copy constructor.

Definition at line 50 of file SGIterator.cxx.

51  : m_proxies (other.m_proxies)
52 {
53  // Maintain shared ownership of elements in our range.
54  this->addRef();
55 }

◆ ~IteratorBase()

SG::detail::IteratorBase::~IteratorBase ( )
protected

Destructor.

Definition at line 61 of file SGIterator.cxx.

62 {
63  // Release ownership of everything in our range.
64  this->release();
65 }

Member Function Documentation

◆ addRef()

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

Add a reference count to all proxies in our range.

◆ const_check()

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

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 }

◆ eql()

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

Equality check.

◆ increment()

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

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

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 }

◆ operator=()

SG::detail::IteratorBase & SG::detail::IteratorBase::operator= ( const IteratorBase other)
protected

Assignment.

Definition at line 72 of file SGIterator.cxx.

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 }

◆ proxy()

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

The proxy pointed at by this iterator.

◆ release()

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

Remove a reference count from all proxies in our range.

◆ setState()

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

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

◆ ::SGImplSvc

friend class ::SGImplSvc
friend

Definition at line 42 of file SGIterator.h.

◆ boost::iterator_core_access

friend class boost::iterator_core_access
friend

Definition at line 39 of file SGIterator.h.

Member Data Documentation

◆ m_proxies

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

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 files:
SG::detail::IteratorBase::proxy
DataProxy * proxy() const
The proxy pointed at by this iterator.
SGTest::store
TestStore store
Definition: TestStore.cxx:23
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:32
SG::ExcConstObject
Exception — Tried to retrieve non-const pointer to const object.
Definition: Control/StoreGate/StoreGate/exceptions.h:134
SGTest::TestStore::name
virtual const std::string & name() const override
Definition: TestStore.cxx:97
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::detail::IteratorBase::release
void release()
Remove a reference count from all proxies in our range.
SG::DataProxy
Definition: DataProxy.h:45
SG::detail::IteratorBase::addRef
void addRef()
Add a reference count to all proxies in our range.