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

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

#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.
const std::string & key () const
 Get the key string with which the current object was stored.

Protected Member Functions

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

Maintains a reference count on proxies within the range.

Definition at line 37 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}
std::vector< SG::DataProxy * > m_proxies
All proxies in our range, in reverse order.
Definition SGIterator.h:146

◆ 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}
void addRef()
Add a reference count to all proxies in our range.

◆ ~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}
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 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}
virtual const std::string & name() const override
Definition TestStore.cxx:97
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 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}

◆ ::SGImplSvc

friend class ::SGImplSvc
friend

Definition at line 43 of file SGIterator.h.

◆ boost::iterator_core_access

friend class boost::iterator_core_access
friend

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


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