ATLAS Offline Software
Loading...
Searching...
No Matches
AthLinks/DataLinkBase.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
11
12
13#ifndef ATHLINKS_DATALINKBASE_H
14#define ATHLINKS_DATALINKBASE_H
15
16
18#include "AthLinks/exceptions.h"
20#include "GaudiKernel/ThreadLocalContext.h"
21
22
23class EventContext;
24
25
26namespace SG {
27class DataProxy;
28template <class INDEXING_POLICY> class GenericElementLinkBase;
29}
30class IProxyDict;
31
32
41{
42public:
45
48
51
54
55
59 bool isDefault() const;
60
61
67 const ID_type& dataID() const;
68
69
75 sgkey_t key() const;
76
77
81 void clear();
82
83
95 SG::DataProxy* proxy (bool nothrow = false) const;
96
97
102
103
104
116
117
126 bool toTransient (const EventContext& ctx = Gaudi::Hive::currentContext());
127
128
141 bool toTransient (const ID_type& dataID, CLID link_clid, IProxyDict* sg);
142
143
154 bool toTransient (const ID_type& dataID, CLID link_clid,
155 const EventContext& ctx = Gaudi::Hive::currentContext());
156
157
174
175
191
192
196 bool operator== (const DataLinkBase& other) const;
197
198
202 bool operator!= (const DataLinkBase& other) const;
203
204
205
206protected:
207 // To get m_proxy from the ctors taking a DataLink+index.
208 friend class ElementLinkBase;
209 template <class INDEXING_POLICY> friend class SG::GenericElementLinkBase;
210
212 friend class DataLinkBase_test;
213
214
219
220
232
233
242 DataLinkBase (const ID_type& dataID, CLID link_clid, IProxyDict* sg);
243
244
256
257
265
266
281 CLID clid_in,
282 IProxyDict* sg);
283
284
297 CLID clid,
298 IProxyDict* sg);
299
300
314 CLID clid,
315 IProxyDict* sg);
316
317
329 void* storableBase (castfn_t* castfn, const CLID& clid, bool isConst) const;
330
331
332
339 void throwInvalidLink() const;
340
341
342
343private:
346
349};
350
351
352namespace SG {
353
354
355inline
357{
358 dl.toTransient (sg);
359 return true;
360}
361
362
363inline
364bool toTransient (DataLinkBase& dl, const EventContext& ctx)
365{
366 dl.toTransient (ctx);
367 return true;
368}
369
370
371} // namespace SG
372
373
375
376
377#endif // not ATHLINKS_DATALINKBASE_H
Manage DataProxy reference in ElementLink/DataLink.
uint32_t CLID
The Class ID type.
Define a hook for running code after an object has been read.
Type-independent part of DataLink; holds the persistent state.
bool operator==(const DataLinkBase &other) const
Compare for equality.
void toIdentifiedObject(sgkey_t key, CLID clid, IProxyDict *sg)
Set the link to an object given by a hashed key.
void toIdentifiedObject(const ID_type &dataID, CLID clid, IProxyDict *sg)
Set the link to an object given by a string key.
bool toPersistent()
Prepare this link for writing.
void throwInvalidLink() const
Throw a ExcInvalidLink exception for this link.
bool toTransient(const ID_type &dataID, CLID link_clid, const EventContext &ctx=Gaudi::Hive::currentContext())
Finish initialization like the link as just been read from root, but with a specified key.
friend class ElementLinkBase
DataLinkBase(const_pointer_t obj, CLID link_clid, IProxyDict *sg)
Constructor from pointer to object.
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
SG::DataProxyHolder::const_pointer_t const_pointer_t
bool isDefault() const
Test to see if we're in the default state.
SG::DataProxyHolder::castfn_t castfn_t
Function casting from a SG::DataProxy to a pointer.
friend class DataLinkBase_test
For component testing.
bool toTransient(IProxyDict *sg)
Finish initialization after link has been read.
DataLinkBase(const ID_type &dataID, CLID link_clid, IProxyDict *sg)
Constructor from a string key.
SG::DataProxy * proxy(bool nothrow=false) const
Return the DataProxy for this link.
void clear()
Clear the link (make it null).
DataLinkBase()
Default constructor.
bool toPersistentNoRemap()
Prepare this link for writing.
bool toTransient(const ID_type &dataID, CLID link_clid, IProxyDict *sg)
Finish initialization like the link as just been read from root, but with a specified key.
sgkey_t m_persKey
The hashed key for this link.
DataLinkBase(sgkey_t key, CLID link_clid, IProxyDict *sg)
Constructor from a hashed key.
const ID_type & dataID() const
Return the SG key that we reference, as a string.
IProxyDict * source() const
Return the data source for this reference.
void * storableBase(castfn_t *castfn, const CLID &clid, bool isConst) const
Return a pointer to the currently-referenced object.
bool operator!=(const DataLinkBase &other) const
Compare for inequality.
DataLinkBase(sgkey_t key, const SG::DataProxyHolder &holder)
Constructor from a hashed key and a proxy holder object.
sgkey_t key() const
Return the SG key that we reference, as a hash.
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
SG::DataProxyHolder::pointer_t pointer_t
void toStorableObject(const_pointer_t obj, CLID clid_in, IProxyDict *sg)
Set the link to an object given by a pointer.
SG::DataProxyHolder m_proxy
SG proxy for this link.
bool toTransient(const EventContext &ctx=Gaudi::Hive::currentContext())
Finish initialization after link has been read.
Manage DataProxy reference in ElementLink/DataLink.
SG::sgkey_t sgkey_t
Type of hashed keys.
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
void * pointer_t
Generic pointer type.
std::string ID_type
Type of string keys.
const void * const_pointer_t
Generic base class for ElementLinks.
Forward declaration.
void toTransient(const EventContext &ctx, SG::auxid_t auxid)
Perform post-read processing for a single variable.