ATLAS Offline Software
Loading...
Searching...
No Matches
DataHandle.icc
Go to the documentation of this file.
1/* -*- C++ -*- */
2
3/*
4 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef STOREGATE_DATAHANDLE_ICC
8#define STOREGATE_DATAHANDLE_ICC
9
10#include "AthenaKernel/DataBucketBase.h"
11
12///////////////////////////////////////////////////////////////////////////////
13// CONSTRUCTORS
14///////////////////////////////////////////////////////////////////////////////
15
16template <class DATA>
17DataHandle<DATA>::DataHandle() :
18 DataHandleBase(),
19 m_ptr(0)
20{ }
21
22//....................................................................
23
24template <class DATA>
25DataHandle<DATA>::DataHandle(const DataHandle& h):
26 DataHandleBase(h),
27 m_ptr(h.m_ptr)
28{}
29
30//....................................................................
31
32template <class DATA>
33DataHandle<DATA>&
34DataHandle<DATA>::DataHandle::operator= (const DataHandle& h)
35{
36 if (this != &h) {
37 this->DataHandleBase::operator=(h);
38 m_ptr = h.m_ptr;
39 }
40 return *this;
41}
42
43//....................................................................
44
45template <class DATA>
46DataHandle<DATA>::DataHandle(SG::DataProxy* proxy) :
47 DataHandleBase(proxy),
48 m_ptr(0)
49{}
50
51//....................................................................
52
53template <class DATA>
54DataHandle<DATA>::DataHandle(const SG::ConstProxyIterator &itr,
55 const SG::ConstProxyIterator &itrEnd) :
56 DataHandleBase(itr, itrEnd),
57 m_ptr(0)
58{}
59
60
61// DESTRUCTOR
62
63template <class DATA>
64DataHandle<DATA>::~DataHandle()
65{
66}
67
68
69///////////////////////////////////////////////////////////////////////////////
70// ITERATION OPERATORS:
71///////////////////////////////////////////////////////////////////////////////
72
73template <class DATA>
74const DataHandle<DATA>&
75DataHandle<DATA>::operator++() const //prefix
76{
77 if (m_proxy) m_proxy->release();
78 m_proxy = 0;
79 m_ptr = 0; // reset pointer to perform retrieveObject
80
81 // set the iterator to the next valid proxy (or end)
82 if (m_useItr && m_itr != m_itrEnd)
83 {
84 while (m_itr != m_itrEnd) {
85 ++m_itr;
86 if (m_itr != m_itrEnd && m_itr->second->isValid() )
87 {
88 m_proxy = (*m_itr).second;
89 break;
90 }
91 }
92 }
93
94 if (m_proxy) m_proxy->addRef();
95 return *this;
96}
97
98///////////////////////////////////////////////////////////////////////////////
99template <class DATA>
100DataHandle<DATA>
101DataHandle<DATA>::operator++ (int) const //postfix
102{
103 DataHandle<DATA> ret(*this);
104 if (m_proxy) m_proxy->release();
105 m_proxy = 0;
106 m_ptr = 0; // reset pointer to perform retrieveObject
107
108 // set the iterator to the next valid proxy (or end)
109 if (m_useItr && m_itr != m_itrEnd)
110 {
111 while (m_itr != m_itrEnd) {
112 ++m_itr;
113 if (m_itr != m_itrEnd && m_itr->second->isValid() )
114 {
115 m_proxy = m_itr->second;
116 break;
117 }
118 }
119 }
120
121 if (m_proxy) m_proxy->addRef();
122 return ret;
123}
124
125
126///////////////////////////////////////////////////////////////////////////////
127// ACCESSOR METHODS:
128///////////////////////////////////////////////////////////////////////////////
129
130
131///////////////////////////////////////////////////////////////////////////////
132
133template <class DATA>
134typename DataHandle<DATA>::const_pointer_type
135DataHandle<DATA>::cptr() const
136{
137 return dataPointer();
138}
139
140///////////////////////////////////////////////////////////////////////////////
141
142// The const version checks if the pointer is a valid pointer.
143// Retrieves the GaudiObject to check validity if not already done
144
145template <class DATA>
146bool
147DataHandle<DATA>::isValid() const
148{
149 // dataPointer() prints a warning if the proxy is null,
150 // so also test isInitialized().
151 return (isInitialized() && 0 != dataPointer());
152}
153
154//////////////////////////////////////////////////////////////////////////////
155template <class DATA>
156typename DataHandle<DATA>::const_pointer_type
157DataHandle<DATA>::dataPointer() const {
158 if (0 == m_ptr) {
159 m_ptr = SG::DataProxy_cast<DATA>(m_proxy);
160 }
161 return m_ptr;
162}
163
164
165//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
166
167
168
169
170#endif // STOREGATE_DATAHANDLE_ICC