4 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
7 #ifndef STOREGATE_DATAHANDLE_ICC
8 #define STOREGATE_DATAHANDLE_ICC
10 #include "AthenaKernel/DataBucketBase.h"
12 ///////////////////////////////////////////////////////////////////////////////
14 ///////////////////////////////////////////////////////////////////////////////
17 DataHandle<DATA>::DataHandle() :
22 //....................................................................
25 DataHandle<DATA>::DataHandle(const DataHandle& h):
30 //....................................................................
34 DataHandle<DATA>::DataHandle::operator= (const DataHandle& h)
37 this->DataHandleBase::operator=(h);
43 //....................................................................
46 DataHandle<DATA>::DataHandle(SG::DataProxy* proxy) :
47 DataHandleBase(proxy),
51 //....................................................................
54 DataHandle<DATA>::DataHandle(const SG::ConstProxyIterator &itr,
55 const SG::ConstProxyIterator &itrEnd) :
56 DataHandleBase(itr, itrEnd),
64 DataHandle<DATA>::~DataHandle()
69 ///////////////////////////////////////////////////////////////////////////////
70 // ITERATION OPERATORS:
71 ///////////////////////////////////////////////////////////////////////////////
74 const DataHandle<DATA>&
75 DataHandle<DATA>::operator++() const //prefix
77 if (m_proxy) m_proxy->release();
79 m_ptr = 0; // reset pointer to perform retrieveObject
81 // set the iterator to the next valid proxy (or end)
82 if (m_useItr && m_itr != m_itrEnd)
84 while (m_itr != m_itrEnd) {
86 if (m_itr != m_itrEnd && m_itr->second->isValid() )
88 m_proxy = (*m_itr).second;
94 if (m_proxy) m_proxy->addRef();
98 ///////////////////////////////////////////////////////////////////////////////
101 DataHandle<DATA>::operator++ (int) const //postfix
103 DataHandle<DATA> ret(*this);
104 if (m_proxy) m_proxy->release();
106 m_ptr = 0; // reset pointer to perform retrieveObject
108 // set the iterator to the next valid proxy (or end)
109 if (m_useItr && m_itr != m_itrEnd)
111 while (m_itr != m_itrEnd) {
113 if (m_itr != m_itrEnd && m_itr->second->isValid() )
115 m_proxy = m_itr->second;
121 if (m_proxy) m_proxy->addRef();
126 ///////////////////////////////////////////////////////////////////////////////
128 ///////////////////////////////////////////////////////////////////////////////
131 ///////////////////////////////////////////////////////////////////////////////
133 template <class DATA>
134 typename DataHandle<DATA>::const_pointer_type
135 DataHandle<DATA>::cptr() const
137 return dataPointer();
140 ///////////////////////////////////////////////////////////////////////////////
142 // The const version checks if the pointer is a valid pointer.
143 // Retrieves the GaudiObject to check validity if not already done
145 template <class DATA>
147 DataHandle<DATA>::isValid() const
149 // dataPointer() prints a warning if the proxy is null,
150 // so also test isInitialized().
151 return (isInitialized() && 0 != dataPointer());
154 //////////////////////////////////////////////////////////////////////////////
155 template <class DATA>
156 typename DataHandle<DATA>::const_pointer_type
157 DataHandle<DATA>::dataPointer() const {
159 m_ptr = SG::DataProxy_cast<DATA>(m_proxy);
165 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
170 #endif // STOREGATE_DATAHANDLE_ICC