ATLAS Offline Software
Loading...
Searching...
No Matches
SG::detail::IteratorBase Class Reference

Implementation class, not to be used directly Iterates over valid proxies in the range. More...

#include <SGIterator.h>

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

Public Member Functions

DataProxy * proxy () const
 The proxy pointed at by this iterator.
const std::string & key () const
 Get the key string with which the current object was stored.

Protected Member Functions

 IteratorBase ()=default
 Default constructor.
 IteratorBase (SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
 Constructor from proxy iterator pair.
template<DataProxyIterator ITERATOR>
 IteratorBase (ITERATOR itr, ITERATOR itrEnd, bool isConst)
 Constructor from iterator pair over DataProxy*.
 IteratorBase (const IteratorBase &other)
 Copy constructor.
 ~IteratorBase ()
 Destructor.
IteratorBase & operator= (const IteratorBase &other)
 Assignment.
StatusCode setState (SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
 Reset state of the iterator.
template<DataProxyIterator ITERATOR>
StatusCode setState (ITERATOR itr, ITERATOR itrEnd, bool isConst)
 Reset state of the iterator.
void increment ()
 Move to the next valid proxy.
bool eql (const IteratorBase &rhs) const
 Equality check.
void const_check () const
 Const check: throw an exception if we're pointing at a const proxy.

Private Member Functions

void addRef ()
 Add a reference count to all proxies in our range.
void release ()
 Remove a reference count from all proxies in our range.

Private Attributes

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

Friends

class boost::iterator_core_access
class ::SGImplSvc

Detailed Description

Implementation class, not to be used directly Iterates over valid proxies in the range.

Maintains a reference count on proxies within the range.

Definition at line 42 of file SGIterator.h.

Constructor & Destructor Documentation

◆ IteratorBase() [1/4]

SG::detail::IteratorBase::IteratorBase ( )
protecteddefault

Default constructor.

◆ IteratorBase() [2/4]

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 23 of file SGIterator.cxx.

26{
27 setState (itr, itrEnd, isConst).ignore();
28}
StatusCode setState(SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
Reset state of the iterator.

◆ IteratorBase() [3/4]

template<DataProxyIterator ITERATOR>
SG::detail::IteratorBase::IteratorBase ( ITERATOR itr,
ITERATOR itrEnd,
bool isConst )
explicitprotected

Constructor from iterator pair over DataProxy*.

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

Will skip ahead to the first valid proxy.

◆ IteratorBase() [4/4]

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

Copy constructor.

Definition at line 34 of file SGIterator.cxx.

35 : m_proxies (other.m_proxies)
36{
37 // Maintain shared ownership of elements in our range.
38 this->addRef();
39}
std::vector< SG::DataProxy * > m_proxies
All proxies in our range, in reverse order.
Definition SGIterator.h:176
void addRef()
Add a reference count to all proxies in our range.

◆ ~IteratorBase()

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

Destructor.

Definition at line 45 of file SGIterator.cxx.

46{
47 // Release ownership of everything in our range.
48 this->release();
49}
void release()
Remove a reference count from all proxies in our range.

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 124 of file SGIterator.cxx.

125{
126 // This should usually not be needed, since we check for constness
127 // when initializing the iterator. However, it is possible for a proxy
128 // to be marked as const after the iterator has been formed, so keep the check.
129 const SG::DataProxy* dp = this->proxy();
130 if (dp->isConst()) {
131 const IProxyDict* store = dp->store();
132 throw SG::ExcConstObject (dp->clID(),
133 dp->name(),
134 store ? store->name() : "(unknown)");
135 }
136}
virtual const std::string & name() const override
DataProxy * proxy() const
The proxy pointed at by this iterator.
TestStore store
Definition TestStore.cxx:23

◆ 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 110 of file SGIterator.cxx.

111{
112 if (!m_proxies.empty()) {
113 m_proxies.back()->release();
114 m_proxies.pop_back();
115 }
116}

◆ key()

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

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

Definition at line 142 of file SGIterator.cxx.

143{
144 return m_proxies.back()->name();
145}

◆ operator=()

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

Assignment.

Definition at line 56 of file SGIterator.cxx.

57{
58 if (this != &other) {
59 // Assign, maintaining refcounts.
60 this->release();
61 m_proxies = other.m_proxies;
62 this->addRef();
63 }
64 return *this;
65}

◆ 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() [1/2]

template<DataProxyIterator ITERATOR>
StatusCode SG::detail::IteratorBase::setState ( ITERATOR itr,
ITERATOR itrEnd,
bool isConst )
protected

Reset state of the iterator.

Parameters
itrStarting iterator over DataProxy*.
itrEndEnding iterator.
isConstIs this for a const iterator?

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

◆ setState() [2/2]

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 78 of file SGIterator.cxx.

81{
82 if (!m_proxies.empty()) {
83 this->release();
84 m_proxies.clear();
85 }
86
87 // Save all valid proxies in reverse order. Also take out a refcount on each.
88 while (itr != itrEnd) {
89 --itrEnd;
90 DataProxy* dp = itrEnd->second;
91 if (dp->isValid() && (isConst || !dp->isConst())) {
92 m_proxies.push_back (dp);
93 dp->addRef();
94 }
95 }
96
97 if (m_proxies.empty()) {
98 return StatusCode::FAILURE;
99 }
100
101 return StatusCode::SUCCESS;
102}

◆ ::SGImplSvc

friend class ::SGImplSvc
friend

Definition at line 48 of file SGIterator.h.

◆ boost::iterator_core_access

friend class boost::iterator_core_access
friend

Definition at line 45 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 176 of file SGIterator.h.


The documentation for this class was generated from the following files: