Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataProxy.icc
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 /***************************************************************************
8  implementation of DataProxy_cast operator
9  -----------------------------------------
10  ATLAS Collaboration
11 ***************************************************************************/
12 
13 // $Id: DataProxy.icc,v 1.6 2008-07-14 22:16:25 calaf Exp $
14 
15 #include "AthenaKernel/DataBucketBase.h"
16 #include "AthenaKernel/StorableConversions.h"
17 #include "AthenaKernel/ClassID_traits.h"
18 #ifndef NDEBUG
19 # include "AthenaKernel/getMessageSvc.h"
20 # include "GaudiKernel/MsgStream.h"
21 #endif
22 
23 
24 class DataObject;
25 
26 
27 /// Retrieve data object key == string
28 inline
29 const SG::DataProxy::name_type& SG::DataProxy::name() const
30 {
31  // No locking needed.
32  return m_tAddress.name();
33 }
34 
35 
36 /// Retrieve data object key == string
37 /// duplicated for Gaudi folks does same as name()
38 inline
39 const SG::DataProxy::id_type& SG::DataProxy::identifier() const
40 {
41  // No locking needed.
42  return m_tAddress.name();
43 }
44 
45 
46 /// Retrieve DataObject
47 inline
48 DataObject* SG::DataProxy::object ATLAS_NOT_CONST_THREAD_SAFE () const
49 {
50  return m_dObject;
51 }
52 
53 
54 /// Retrieve IOpaqueAddress
55 inline
56 IOpaqueAddress* SG::DataProxy::address() const
57 {
58  lock_t lock (m_mutex);
59  return m_tAddress.address();
60 }
61 
62 
63 /// set DataSvc (Gaudi-specific); do nothing for us
64 inline
65 IDataProviderSvc* SG::DataProxy::dataSvc() const
66 {
67  return nullptr;
68 }
69 
70 ///< Get the primary (hashed) SG key.
71 inline
72 SG::sgkey_t SG::DataProxy::sgkey() const
73 {
74  // No lock; underlying member is atomic.
75  return m_tAddress.sgkey();
76 }
77 
78 
79 /// Set the primary (hashed) SG key.
80 inline
81 void SG::DataProxy::setSGKey (sgkey_t sgkey)
82 {
83  lock_t lock (m_mutex);
84  m_tAddress.setSGKey (sgkey);
85 }
86 
87 
88 ///< Return the ID of the store containing this proxy.
89 inline
90 StoreID::type SG::DataProxy::storeID() const
91 {
92  lock_t lock (m_mutex);
93  return m_tAddress.storeID();
94 }
95 
96 
97 ///< check if it is a transient ID (primary or symLinked):
98 inline
99 bool SG::DataProxy::transientID (CLID id) const
100 {
101  lock_t lock (m_mutex);
102  return m_tAddress.transientID (id);
103 }
104 
105 
106 ///< return the list of transient IDs (primary or symLinked):
107 inline
108 SG::DataProxy::CLIDCont_t SG::DataProxy::transientID() const
109 {
110  lock_t lock (m_mutex);
111  return m_tAddress.transientID();
112 }
113 
114 
115 /// Add a new transient ID
116 inline
117 void SG::DataProxy::setTransientID(CLID id)
118 {
119  lock_t lock (m_mutex);
120  m_tAddress.setTransientID (id);
121 }
122 
123 
124 /// access set of proxy aliases
125 /// Returns a COPY of the alias set.
126 inline
127 SG::DataProxy::AliasCont_t SG::DataProxy::alias() const
128 {
129  lock_t lock (m_mutex);
130  return m_tAddress.alias();
131 }
132 
133 
134 /// Add a new proxy alias.
135 inline
136 void SG::DataProxy::setAlias(const std::string& key)
137 {
138  lock_t lock (m_mutex);
139  m_tAddress.setAlias (key);
140 }
141 
142 
143 /// Test to see if a given string is in the alias set.
144 inline
145 bool SG::DataProxy::hasAlias(const std::string& key) const
146 {
147  lock_t lock (m_mutex);
148  return m_tAddress.hasAlias (key);
149 }
150 
151 
152 /// remove alias from proxy
153 inline
154 bool SG::DataProxy::removeAlias(const std::string& key)
155 {
156  lock_t lock (m_mutex);
157  return m_tAddress.removeAlias (key);
158 }
159 
160 
161 /// Return the address provider.
162 inline
163 IAddressProvider* SG::DataProxy::provider()
164 {
165  lock_t lock (m_mutex);
166  return m_tAddress.provider();
167 }
168 
169 
170 /// Set the address provider.
171 inline
172 void SG::DataProxy::setProvider(IAddressProvider* provider,
173  StoreID::type storeID)
174 {
175  lock_t lock (m_mutex);
176  m_tAddress.setProvider (provider, storeID);
177 }
178 
179 
180 /// Set the CLID / key.
181 /// This will only succeed if the clid/key are currently clear.
182 inline
183 void SG::DataProxy::setID (CLID id, const std::string& key)
184 {
185  lock_t lock (m_mutex);
186  m_tAddress.setID (id, key);
187 }
188 
189 
190 /// am I valid?
191 inline
192 bool SG::DataProxy::isValid() const
193 {
194  return (isValidObject() || isValidAddress());
195 }
196 
197 
198 /// is the object valid?
199 inline
200 bool SG::DataProxy::isValidObject() const
201 {
202  // FIXME: should we try to chase?
203  return (0!= m_dObject);
204 }
205 
206 
207 /// Access DataObject on-demand using conversion service
208 ///@throws runtime_error when converter fails
209 inline
210 DataObject* SG::DataProxy::accessData()
211 {
212  // Inlined part: return m_dObject if it's valid.
213  // Otherwise, call the out-of-line part of the code.
214  if (0 != m_dObject) return m_dObject; // cached object
215  return accessDataOol();
216 }
217 
218 
219 inline
220 SG::DataProxy::ErrNo SG::DataProxy::errNo() const
221 {
222  lock_t lock (m_objMutex);
223  return m_errno;
224 }
225 
226 
227 /// Retrieve clid
228 inline
229 CLID SG::DataProxy::clID() const
230 {
231  // No lock; underlying member is atomic.
232  return m_tAddress.clID();
233 }
234 
235 
236 /// Check if it is a const object
237 inline
238 bool SG::DataProxy::isConst() const
239 {
240  // No lock; underlying member is atomic.
241  return m_const;
242 }
243 
244 
245 /// set the reset only flag: Clear Store will reset and not delete.
246 inline
247 void SG::DataProxy::resetOnly(const bool& flag)
248 {
249  lock_t lock (m_mutex);
250  m_resetFlag = flag;
251 }
252 
253 
254 /// Check reset only:
255 inline
256 bool SG::DataProxy::isResetOnly() const
257 {
258  lock_t lock (m_mutex);
259  return m_resetFlag;
260 }
261 
262 
263 /// Set the store of which we're a part.
264 inline
265 void SG::DataProxy::setStore (IProxyDict* store)
266 {
267  m_store = store;
268 }
269 
270 /// Return the store of which we're a part.
271 inline
272 IProxyDict* SG::DataProxy::store()
273 {
274  return m_store;
275 }
276 
277 
278 /// Return the store of which we're a part.
279 inline
280 const IProxyDict* SG::DataProxy::store() const
281 {
282  return m_store;
283 }
284 
285 
286 inline
287 IConverter* SG::DataProxy::loader()
288 {
289  lock_t lock (m_mutex);
290  return m_dataLoader;
291 }
292 
293 
294