ATLAS Offline Software
Public Types | Public Member Functions | List of all members
DataHandleBase Class Referenceabstract

an iterator over instances of a given type in an IProxyDict (such as 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) More...

#include <DataHandleBase.h>

Inherits IResetable.

Inherited by DataHandle< DATA >, DataHandle< AthenaAttributeList >, DataHandle< CaloRec::CaloCellFactor >, DataHandle< CondAttrListCollection >, DataHandle< CondMultChanCollection >, DataHandle< GenericDbTable >, DataHandle< ILArAutoCorr >, DataHandle< ILArPedestal >, DataHandle< ILArShape >, and DataHandle< StrawDxContainer >.

Collaboration diagram for DataHandleBase:

Public Types

typedef std::string ID_type
 

Public Member Functions

 DataHandleBase ()
 Default constructor: More...
 
 DataHandleBase (const DataHandleBase &rhs)
 Copy constructor: More...
 
DataHandleBaseoperator= (const DataHandleBase &rhs)
 Assignment operator: More...
 
 DataHandleBase (SG::DataProxy *proxy)
 Constructor with parameters: More...
 
 DataHandleBase (const SG::ConstProxyIterator &itr1, const SG::ConstProxyIterator &itr2)
 
virtual ~DataHandleBase ()
 Destructor: More...
 
virtual void reset (bool hard)=0
 Clear cached data from this object. More...
 
virtual void finalReset ()
 optional special action on final reset call (e.g. in caller destructor) More...
 

validity checks

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

Detailed Description

an iterator over instances of a given type in an IProxyDict (such as 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)

Definition at line 37 of file DataHandleBase.h.

Member Typedef Documentation

◆ ID_type

typedef std::string DataHandleBase::ID_type

Definition at line 44 of file DataHandleBase.h.

Constructor & Destructor Documentation

◆ DataHandleBase() [1/4]

DataHandleBase::DataHandleBase ( )

Default constructor:

Definition at line 27 of file DataHandleBase.cxx.

27  :
28  IResetable(),
29  m_itr(),
30  m_itrEnd(),
31  m_proxy(0),
32  //m_ptr(0),
33  m_useItr(false)
34 {}

◆ DataHandleBase() [2/4]

DataHandleBase::DataHandleBase ( const DataHandleBase rhs)

Copy constructor:

Definition at line 37 of file DataHandleBase.cxx.

37  :
38  IResetable(),
39  m_itr(rhs.m_itr),
40  m_itrEnd(rhs.m_itrEnd),
41  m_proxy(rhs.m_proxy),
42  //m_ptr(rhs.m_ptr),
43  m_useItr(rhs.m_useItr)
44 {
45  if (m_proxy) {
46  m_proxy->addRef();
47  }
48 }

◆ DataHandleBase() [3/4]

DataHandleBase::DataHandleBase ( SG::DataProxy proxy)

Constructor with parameters:

Definition at line 74 of file DataHandleBase.cxx.

74  :
75  IResetable(),
76  m_itr(),
77  m_itrEnd(),
78  m_proxy(proxy),
79  //m_ptr(0),
80  m_useItr(false)
81 {
82  if (m_proxy) {
83  m_proxy->addRef();
84  }
85 }

◆ DataHandleBase() [4/4]

DataHandleBase::DataHandleBase ( const SG::ConstProxyIterator itr1,
const SG::ConstProxyIterator itr2 
)

Definition at line 87 of file DataHandleBase.cxx.

88  :
89  IResetable(),
90  m_itr(itr),
91  m_itrEnd(itrEnd),
92  m_proxy(0),
93  //m_ptr(0),
94  m_useItr(true)
95 {
96  if (m_itr != m_itrEnd) {
97  m_proxy = m_itr->second;
98  }
99 
100  if (m_proxy) {
101  m_proxy->addRef();
102  }
103 }

◆ ~DataHandleBase()

DataHandleBase::~DataHandleBase ( )
virtual

Destructor:

Definition at line 107 of file DataHandleBase.cxx.

108 {
109  if (m_proxy != 0) {
110  m_proxy->unbindHandle(this);
111  m_proxy->release();
112  }
113 }

Member Function Documentation

◆ clid()

virtual CLID DataHandleBase::clid ( ) const
pure virtual

the CLID of the object we are bound to

Implemented in DataHandle< DATA >.

◆ 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
inline

get the data object key (ID)

Definition at line 94 of file DataHandleBase.h.

94 { return isInitialized() ? m_proxy->name() : "NONE"; }

◆ isConst()

bool DataHandleBase::isConst ( ) const

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

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()

bool DataHandleBase::isSet ( ) const
inlinevirtual

Implements IResetable.

Definition at line 77 of file DataHandleBase.h.

77 { return isInitialized(); }

◆ key()

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

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 }

◆ operator=()

DataHandleBase & DataHandleBase::operator= ( const DataHandleBase rhs)

Assignment operator:

Definition at line 53 of file DataHandleBase.cxx.

54 {
55  if (this != &rhs) {
56  if (m_proxy) {
57  m_proxy->release();
58  }
59 
60  m_itr = rhs.m_itr;
61  m_itrEnd = rhs.m_itrEnd;
62  m_useItr = rhs.m_useItr;
63  m_proxy = rhs.m_proxy;
64  //m_ptr = rhs.m_ptr;
65  if (m_proxy) {
66  m_proxy->addRef();
67  }
68  }
69 
70  return *this;
71 }

◆ reset()

virtual void IResetable::reset ( bool  hard)
pure virtualinherited

Clear cached data from this object.

If HARD is true, then also clear any data that depends on the identity of the current event store. HARD will be set if the handle could potentially be looking at a different store the next time it is used. (This happens in Hive.)

For example, a VarHandle caches both a pointer to the referenced object and a pointer to the DataProxy used to reference it. If HARD is false, then only the object pointer need be cleared; but if it is true, then the DataProxy pointer should be cleared as well (and the object deregistered from the store).

Implemented in DataHandle< DATA >, DataHandle< ILArPedestal >, DataHandle< CondAttrListCollection >, DataHandle< ILArShape >, DataHandle< CondMultChanCollection >, DataHandle< ILArAutoCorr >, DataHandle< CaloRec::CaloCellFactor >, DataHandle< AthenaAttributeList >, DataHandle< GenericDbTable >, DataHandle< StrawDxContainer >, SG::VarHandleBase, and SG::UpdateHandle< T >.

◆ setState() [1/5]

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

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 }

◆ setState() [2/5]

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

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

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 }

◆ setState() [4/5]

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

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

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 }

Member Data Documentation

◆ m_itr

SG::ConstProxyIterator DataHandleBase::m_itr
mutableprotected

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
mutableprotected

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
mutableprotected

the proxy holding the object we are bound to

Definition at line 115 of file DataHandleBase.h.

◆ m_useItr

bool DataHandleBase::m_useItr
mutableprotected

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 files:
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
DataHandleBase
an iterator over instances of a given type in an IProxyDict (such as StoreGateSvc)....
Definition: DataHandleBase.h:38
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
SG::DataProxy::isConst
bool isConst() const
Check if it is a const object.
DataHandleBase::clid
virtual CLID clid() const =0
the CLID of the object we are bound to
DataHandleBase::m_useItr
bool m_useItr
use the proxy-iterator or just the proxy ?
Definition: DataHandleBase.h:118
SG::DataProxy::unbindHandle
void unbindHandle(IResetable *ir)
Definition: DataProxy.cxx:293
DataHandleBase::m_itrEnd
SG::ConstProxyIterator m_itrEnd
iterator pointing at the end of the range of proxies
Definition: DataHandleBase.h:112
IResetable
a resetable object (e.g. a SG DataHandle)
Definition: IResetable.h:15
DataHandleBase::key
const std::string & key() const
Get the key string with which the current object was stored.
Definition: DataHandleBase.cxx:186
DataHandleBase::setState
StatusCode setState(SG::DataProxy *proxy) const
Definition: DataHandleBase.cxx:156
DataHandleBase::m_itr
SG::ConstProxyIterator m_itr
iterator pointing at the beginning of the range of proxies
Definition: DataHandleBase.h:109
DataHandleBase::m_proxy
SG::DataProxy * m_proxy
the proxy holding the object we are bound to
Definition: DataHandleBase.h:115
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::DataProxy::release
virtual unsigned long release() override final
release reference to object
Definition: DataProxy.cxx:320
StoreGateSvc::proxy
virtual SG::DataProxy * proxy(const void *const pTransient) const override final
get proxy for a given data object address in memory
SG::DataProxy::addRef
virtual unsigned long addRef() override final
Add reference to object.
Definition: DataProxy.cxx:313
SG::DataProxy::name
virtual const name_type & name() const override final
Retrieve data object key == string.
DataHandleBase::isInitialized
bool isInitialized() const
weaker test but it does not touch the disk!
Definition: DataHandleBase.cxx:207
IResetable::reset
virtual void reset(bool hard)=0
Clear cached data from this object.
SG::DataProxy
Definition: DataProxy.h:44