ATLAS Offline Software
Loading...
Searching...
No Matches
DataHandle< DATA > Class Template Reference

an iterator over instances of a given type in StoreGateSvc. More...

#include <DataHandle.h>

Inheritance diagram for DataHandle< DATA >:
Collaboration diagram for DataHandle< DATA >:

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = DATA
using difference_type = std::ptrdiff_t
using pointer = value_type*
using reference = value_type&
typedef pointer pointer_type
using const_pointer_type = const DATA*
using reference_type = reference
using const_reference_type = const DATA&
typedef DataHandleBase::ID_type ID_type

Public Member Functions

virtual void finalReset ()
 optional special action on final reset call (e.g. in caller destructor)
constructors and assignment
 DataHandle ()
 DataHandle (const DataHandle &h)
DataHandleoperator= (const DataHandle &h)
DataHandleoperator= (const DATA &d)
virtual ~DataHandle ()
 unbind from the proxy before we go
validity checks
bool isValid () const
 RETRIEVES the DO to check it is valid and unlocked.
bool operator! () const
 DEPRECATED for statements like: if (!DataHandle<XXX>) {...}.
 operator int () const
 DEPRECATED for statements like: if (DataHandle<XXX>) {...}.
iterator interface
const DataHandleoperator++ () const
 prefix
DataHandle operator++ (int) const
 postfix
const_pointer_type operator-> () const
const_reference_type operator* () const
access to the underlying ptr
 operator const_pointer_type () const
 often ambiguous
const_pointer_type cptr () const
 safer explicit ptr accessor
virtual void reset (bool) override
 reset pointer

other constructors and methods for SG internal use

const_pointer_type m_ptr
 DataHandle (SG::DataProxy *proxy)
 DataHandle (const SG::ConstProxyIterator &itr1, const SG::ConstProxyIterator &itr2)
virtual CLID clid () const override
 the CLID of the object we are bound to
bool operator==ATLAS_NOT_THREAD_SAFE (const DataHandle< DATA > &h1, const DataHandle< DATA > &h2)
bool operator!=ATLAS_NOT_THREAD_SAFE (const DataHandle< DATA > &h1, const DataHandle< DATA > &h2)
const_pointer_type dataPointer () const

validity checks

bool isConst () const
bool isInitialized () const
 weaker test but it does not touch the disk!
virtual bool isSet () const override
virtual const std::string & key () const override
 Get the key string with which the current object was stored.
StatusCode setState (SG::DataProxy *proxy) const
StatusCode setState (IProxyDict *store, const ID_type &name) const
StatusCode setState (SG::ConstProxyIterator &itr1, const SG::ConstProxyIterator &itr2) const
StatusCode setState (SG::DataProxy *proxy)
StatusCode setState (IProxyDict *store, const ID_type &name)
ID_type ID () const
 get the data object key (ID)
SG::ConstProxyIterator m_itr
 iterator pointing at the beginning of the range of proxies
SG::ConstProxyIterator m_itrEnd
 iterator pointing at the end of the range of proxies
SG::DataProxym_proxy
 the proxy holding the object we are bound to
bool m_useItr
 use the proxy-iterator or just the proxy ?

Detailed Description

template<typename DATA>
class DataHandle< DATA >

an iterator over instances of a given type in StoreGateSvc.

It d-casts and caches locally the pointed-at object, to speed-up subsequent accesses. It can be reset by the store for asynchronous updates (IOVSvc)

Holds a reference count on the proxy to which it's currently pointing. Note: one may think that we should hold reference counts for the entire range which the DataHandle references (if it is a range). The problem with this is that the range may change underneath us. For example, if someone does a SG record, then a new element may appear within the range. So we only hold the refcount for the object to which we're currently pointing.

Parameters
DATAthe data object type
Author
ATLAS Collaboration

Definition at line 41 of file DataHandle.h.

Member Typedef Documentation

◆ const_pointer_type

template<typename DATA>
using DataHandle< DATA >::const_pointer_type = const DATA*

Definition at line 52 of file DataHandle.h.

◆ const_reference_type

template<typename DATA>
using DataHandle< DATA >::const_reference_type = const DATA&

Definition at line 54 of file DataHandle.h.

◆ difference_type

template<typename DATA>
using DataHandle< DATA >::difference_type = std::ptrdiff_t

Definition at line 47 of file DataHandle.h.

◆ ID_type

template<typename DATA>
typedef DataHandleBase::ID_type DataHandle< DATA >::ID_type

Definition at line 56 of file DataHandle.h.

◆ iterator_category

template<typename DATA>
using DataHandle< DATA >::iterator_category = std::forward_iterator_tag

Definition at line 45 of file DataHandle.h.

◆ pointer

template<typename DATA>
using DataHandle< DATA >::pointer = value_type*

Definition at line 48 of file DataHandle.h.

◆ pointer_type

template<typename DATA>
typedef pointer DataHandle< DATA >::pointer_type

Definition at line 51 of file DataHandle.h.

◆ reference

template<typename DATA>
using DataHandle< DATA >::reference = value_type&

Definition at line 49 of file DataHandle.h.

◆ reference_type

template<typename DATA>
using DataHandle< DATA >::reference_type = reference

Definition at line 53 of file DataHandle.h.

◆ value_type

template<typename DATA>
using DataHandle< DATA >::value_type = DATA

Definition at line 46 of file DataHandle.h.

Constructor & Destructor Documentation

◆ DataHandle() [1/4]

template<typename DATA>
DataHandle< DATA >::DataHandle ( )

◆ DataHandle() [2/4]

template<typename DATA>
DataHandle< DATA >::DataHandle ( const DataHandle< DATA > & h)

◆ ~DataHandle()

template<typename DATA>
virtual DataHandle< DATA >::~DataHandle ( )
virtual

unbind from the proxy before we go

◆ DataHandle() [3/4]

template<typename DATA>
DataHandle< DATA >::DataHandle ( SG::DataProxy * proxy)

◆ DataHandle() [4/4]

template<typename DATA>
DataHandle< DATA >::DataHandle ( const SG::ConstProxyIterator & itr1,
const SG::ConstProxyIterator & itr2 )

Member Function Documentation

◆ clid()

template<typename DATA>
virtual CLID DataHandle< DATA >::clid ( ) const
inlineoverridevirtual

the CLID of the object we are bound to

Implements DataHandleBase.

Definition at line 120 of file DataHandle.h.

◆ cptr()

template<typename DATA>
const_pointer_type DataHandle< DATA >::cptr ( ) const

safer explicit ptr accessor

◆ dataPointer()

template<typename DATA>
const_pointer_type DataHandle< DATA >::dataPointer ( ) const
private

◆ finalReset()

virtual void IResetable::finalReset ( )
inlinevirtualinherited

optional special action on final reset call (e.g. in caller destructor)

Reimplemented in SG::VarHandleBase.

Definition at line 33 of file IResetable.h.

33{};

◆ ID()

ID_type DataHandleBase::ID ( ) const
inlineinherited

get the data object key (ID)

Definition at line 94 of file DataHandleBase.h.

94{ return isInitialized() ? m_proxy->name() : "NONE"; }
SG::DataProxy * m_proxy
the proxy holding the object we are bound to
bool isInitialized() const
weaker test but it does not touch the disk!

◆ isConst()

bool DataHandleBase::isConst ( ) const
inherited

Definition at line 196 of file DataHandleBase.cxx.

197{
198 return 0 != m_proxy
199 ? m_proxy->isConst()
200 : false;
201}

◆ isInitialized()

bool DataHandleBase::isInitialized ( ) const
inherited

weaker test but it does not touch the disk!

Definition at line 207 of file DataHandleBase.cxx.

208{
209 return (0 != m_proxy);
210}

◆ isSet()

virtual bool DataHandleBase::isSet ( ) const
inlineoverridevirtualinherited

Implements IResetable.

Definition at line 77 of file DataHandleBase.h.

77{ return isInitialized(); }

◆ isValid()

template<typename DATA>
bool DataHandle< DATA >::isValid ( ) const

RETRIEVES the DO to check it is valid and unlocked.

◆ key()

const std::string & DataHandleBase::key ( ) const
overridevirtualinherited

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

Implements IResetable.

Definition at line 186 of file DataHandleBase.cxx.

187{
188 if (m_itr == m_itrEnd) {
189 return m_proxy->name();
190 } else {
191 return m_itr->first;
192 }
193}
SG::ConstProxyIterator m_itrEnd
iterator pointing at the end of the range of proxies
SG::ConstProxyIterator m_itr
iterator pointing at the beginning of the range of proxies

◆ operator const_pointer_type()

template<typename DATA>
DataHandle< DATA >::operator const_pointer_type ( ) const
inline

often ambiguous

Definition at line 104 of file DataHandle.h.

◆ operator int()

template<typename DATA>
DataHandle< DATA >::operator int ( ) const
inline

DEPRECATED for statements like: if (DataHandle<XXX>) {...}.

Definition at line 89 of file DataHandle.h.

89{ return isValid(); }
bool isValid() const
RETRIEVES the DO to check it is valid and unlocked.

◆ operator!()

template<typename DATA>
bool DataHandle< DATA >::operator! ( ) const
inline

DEPRECATED for statements like: if (!DataHandle<XXX>) {...}.

Definition at line 85 of file DataHandle.h.

85{ return !isValid(); }

◆ operator*()

template<typename DATA>
const_reference_type DataHandle< DATA >::operator* ( ) const
inline

Definition at line 99 of file DataHandle.h.

99{ return *cptr(); }
const_pointer_type cptr() const
safer explicit ptr accessor

◆ operator++() [1/2]

template<typename DATA>
const DataHandle & DataHandle< DATA >::operator++ ( ) const

prefix

◆ operator++() [2/2]

template<typename DATA>
DataHandle DataHandle< DATA >::operator++ ( int ) const

postfix

◆ operator->()

template<typename DATA>
const_pointer_type DataHandle< DATA >::operator-> ( ) const
inline

Definition at line 97 of file DataHandle.h.

97{ return cptr(); }

◆ operator=() [1/2]

template<typename DATA>
DataHandle & DataHandle< DATA >::operator= ( const DATA & d)
inline

Definition at line 63 of file DataHandle.h.

64 {
66 if (ptr) {
67 *ptr = d;
68 } else {
69 std::cerr << "invalid proxy\n";
70 }
71 return *this;
72 }
an iterator over instances of a given type in StoreGateSvc.
Definition DataHandle.h:43
const_pointer_type m_ptr
Definition DataHandle.h:140

◆ operator=() [2/2]

template<typename DATA>
DataHandle & DataHandle< DATA >::operator= ( const DataHandle< DATA > & h)

◆ reset()

template<typename DATA>
virtual void DataHandle< DATA >::reset ( bool )
inlineoverridevirtual

reset pointer

Implements IResetable.

Definition at line 108 of file DataHandle.h.

◆ setState() [1/5]

StatusCode DataHandleBase::setState ( IProxyDict * store,
const ID_type & name )
inherited

Definition at line 235 of file DataHandleBase.cxx.

236{
237 if (0 == store) {
238 return StatusCode::FAILURE;
239 }
240 CLID cid = this->clid();
241 SG::DataProxy* proxy = store->proxy(cid, key);
242 return this->setState(proxy);
243}
uint32_t CLID
The Class ID type.
StatusCode setState(SG::DataProxy *proxy) const
virtual const std::string & key() const override
Get the key string with which the current object was stored.
virtual CLID clid() const =0
the CLID of the object we are bound to
virtual SG::DataProxy * proxy(const void *const pTransient) const override
TestStore store
Definition TestStore.cxx:23

◆ setState() [2/5]

StatusCode DataHandleBase::setState ( IProxyDict * store,
const ID_type & name ) const
inherited

Definition at line 175 of file DataHandleBase.cxx.

176{
177 if (0 == store) {
178 return StatusCode::FAILURE;
179 }
180 CLID cid = this->clid();
181 SG::DataProxy* proxy = store->proxy(cid, key);
182 return this->setState(proxy);
183}

◆ setState() [3/5]

StatusCode DataHandleBase::setState ( SG::ConstProxyIterator & itr1,
const SG::ConstProxyIterator & itr2 ) const
inherited

Definition at line 123 of file DataHandleBase.cxx.

125{
126 if (m_proxy) m_proxy->release();
127
128 m_itr = itr;
129 m_itrEnd = itrEnd;
130 m_useItr = true;
131
132 // ouch! FIXME ?
133 // we could have a void* m_ptr data member and have a
134 // typeless_dataPointer method using the typeless machinery of
135 // DataProxy+DataBucketBase...
136 const_cast<DataHandleBase*>(this)->reset (false);
137
138 // scan from itr to itrEnd and set m_itr to the first valid iterator:
139
140 for (; itr != itrEnd; ++itr) {
141 if (itr->second->isValid()) {
142 m_itr = itr;
143 m_proxy = m_itr->second;
144 if (m_proxy) m_proxy->addRef();
145 return StatusCode::SUCCESS;
146 }
147 }
148
149 m_itr = itrEnd;
150 m_proxy = 0;
151
152 return StatusCode::FAILURE;
153}
DataHandleBase()
Default constructor:
bool m_useItr
use the proxy-iterator or just the proxy ?
virtual void reset(bool hard)=0
Clear cached data from this object.

◆ setState() [4/5]

StatusCode DataHandleBase::setState ( SG::DataProxy * proxy)
inherited

Definition at line 217 of file DataHandleBase.cxx.

218{
219 if (0 == proxy || !proxy->isValid() || proxy->isConst()) {
220 return StatusCode::FAILURE;
221 }
222
223 if (m_proxy != proxy) {
224 if (m_proxy) m_proxy->release();
225 m_proxy = proxy;
226 m_proxy->addRef();
227 }
228
229 m_useItr = false;
230 this->reset (false);
231 return StatusCode::SUCCESS;
232}

◆ setState() [5/5]

StatusCode DataHandleBase::setState ( SG::DataProxy * proxy) const
inherited

Definition at line 156 of file DataHandleBase.cxx.

157{
158 if (0 == proxy || !proxy->isValid()) {
159 return StatusCode::FAILURE;
160 }
161
162 if (m_proxy != proxy) {
163 if (m_proxy) m_proxy->release();
164 m_proxy = proxy;
165 m_proxy->addRef();
166 }
167
168 m_useItr = false;
169 const_cast<DataHandleBase*>(this)->reset (false);
170
171 return StatusCode::SUCCESS;
172}

◆ operator!=ATLAS_NOT_THREAD_SAFE

template<typename DATA>
bool operator!=ATLAS_NOT_THREAD_SAFE ( const DataHandle< DATA > & h1,
const DataHandle< DATA > & h2 )
friend

Definition at line 130 of file DataHandle.h.

132 {
133 return h1.m_proxy != h2.m_proxy;
134 }

◆ operator==ATLAS_NOT_THREAD_SAFE

template<typename DATA>
bool operator==ATLAS_NOT_THREAD_SAFE ( const DataHandle< DATA > & h1,
const DataHandle< DATA > & h2 )
friend

Definition at line 123 of file DataHandle.h.

125 {
126 return h1.m_proxy == h2.m_proxy;
127 }

Member Data Documentation

◆ m_itr

SG::ConstProxyIterator DataHandleBase::m_itr
mutableprotectedinherited

iterator pointing at the beginning of the range of proxies

Definition at line 109 of file DataHandleBase.h.

◆ m_itrEnd

SG::ConstProxyIterator DataHandleBase::m_itrEnd
mutableprotectedinherited

iterator pointing at the end of the range of proxies

Definition at line 112 of file DataHandleBase.h.

◆ m_proxy

SG::DataProxy* DataHandleBase::m_proxy
mutableprotectedinherited

the proxy holding the object we are bound to

Definition at line 115 of file DataHandleBase.h.

◆ m_ptr

template<typename DATA>
const_pointer_type DataHandle< DATA >::m_ptr
mutableprivate

Definition at line 140 of file DataHandle.h.

◆ m_useItr

bool DataHandleBase::m_useItr
mutableprotectedinherited

use the proxy-iterator or just the proxy ?

Definition at line 118 of file DataHandleBase.h.


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