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-2025 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
21
22class EventContext;
23
24
25namespace SG {
26class DataProxy;
27template <class INDEXING_POLICY> class GenericElementLinkBase;
28}
29class IProxyDict;
30
31
40{
41public:
44
47
50
53
54
58 bool isDefault() const;
59
60
66 const ID_type& dataID() const;
67
68
74 sgkey_t key() const;
75
76
80 void clear();
81
82
94 SG::DataProxy* proxy (bool nothrow = false) const;
95
96
101
102
103
114 bool toTransient (IProxyDict* sg = 0);
115
116
125 bool toTransient (const EventContext& ctx);
126
127
140 bool toTransient (const ID_type& dataID, CLID link_clid, IProxyDict* sg = 0);
141
142
153 bool toTransient (const ID_type& dataID, CLID link_clid,
154 const EventContext& ctx);
155
156
173
174
190
191
195 bool operator== (const DataLinkBase& other) const;
196
197
201 bool operator!= (const DataLinkBase& other) const;
202
203
204
205protected:
206 // To get m_proxy from the ctors taking a DataLink+index.
207 friend class ElementLinkBase;
208 template <class INDEXING_POLICY> friend class SG::GenericElementLinkBase;
209
211 friend class DataLinkBase_test;
212
213
218
219
231
232
241 DataLinkBase (const ID_type& dataID, CLID link_clid, IProxyDict* sg);
242
243
255
256
264
265
280 CLID clid_in,
281 IProxyDict* sg);
282
283
296 CLID clid,
297 IProxyDict* sg);
298
299
313 CLID clid,
314 IProxyDict* sg);
315
316
328 void* storableBase (castfn_t* castfn, const CLID& clid, bool isConst) const;
329
330
331
338 void throwInvalidLink() const;
339
340
341
342private:
345
348};
349
350
351namespace SG {
352
353
354inline
356{
357 dl.toTransient (sg);
358 return true;
359}
360
361
362inline
363bool toTransient (DataLinkBase& dl, const EventContext& ctx)
364{
365 dl.toTransient (ctx);
366 return true;
367}
368
369
370} // namespace SG
371
372
374
375
376#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.
friend class ElementLinkBase
bool toTransient(const ID_type &dataID, CLID link_clid, IProxyDict *sg=0)
Finish initialization like the link as just been read from root, but with a specified key.
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.
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).
bool toTransient(const EventContext &ctx)
Finish initialization after link has been read.
DataLinkBase()
Default constructor.
bool toPersistentNoRemap()
Prepare this link for writing.
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.
bool toTransient(IProxyDict *sg=0)
Finish initialization after link has been read.
sgkey_t key() const
Return the SG key that we reference, as a hash.
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
bool toTransient(const ID_type &dataID, CLID link_clid, const EventContext &ctx)
Finish initialization like the link as just been read from root, but with a specified key.
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.
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.