ATLAS Offline Software
Loading...
Searching...
No Matches
DataProxyHolder.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/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
12
13
14#ifndef ATHLINKS_DATAPROXYHOLDER_H
15#define ATHLINKS_DATAPROXYHOLDER_H
16
17
18#include "SGCore/sgkey_t.h"
19#include "GaudiKernel/ClassID.h"
20#include <string>
21#include <unordered_map>
22#include <cassert>
23
24
25class IProxyDict;
26
27
28namespace SG {
29
30
31class ThinningCache;
32class DataProxy;
33
34
62{
63public:
66
68 using ID_type = std::string;
69
71 using pointer_t = void*;
72 using const_pointer_t = const void*;
73
75 typedef void* castfn_t (SG::DataProxy*);
76
77
84
85
96 template <class FROM_STORABLE, class TO_STORABLE>
97 DataProxyHolder (const DataProxyHolder& other, FROM_STORABLE*, TO_STORABLE*);
98
99
102
103
107 void clear();
108
109
129 CLID link_clid,
130 IProxyDict* sg);
131
132
150 CLID link_clid,
151 IProxyDict* sg);
152
153
170 void toIdentifiedObject (sgkey_t key,
171 CLID link_clid,
172 IProxyDict* sg);
173
174
178 bool isDefault() const;
179
180
186 const ID_type& dataID() const;
187
188
200 void* storableBase (castfn_t* castfn, CLID clid, bool isConst) const;
201
202
203
216 SG::DataProxy* proxy (bool nothrow = false) const;
217
218
226 IProxyDict* source() const;
227
228
240 void toTransient (sgkey_t sgkey, IProxyDict* sg = 0);
241
242
257 CLID link_clid,
258 IProxyDict* sg = 0);
259
260
276 void toPersistentNoRemap (sgkey_t& sgkey);
277
278
299 bool toPersistent (sgkey_t& sgkey, uint64_t& index);
300
301
322 bool toPersistent (sgkey_t& sgkey, uint32_t& index);
323
324
343 template <class T>
344 bool toPersistent (sgkey_t& sgkey, const T& /*index*/);
345
346
359 static
360 bool thin (sgkey_t& sgkey, size_t& index,
361 const SG::ThinningCache* thinningCache);
362
363
367 bool operator== (const DataProxyHolder& other) const;
368
369
376 void throwInvalidLink (sgkey_t sgkey) const;
377
378
379private:
385 bool isObjpointer() const;
386
387
394
395
403
404
416 SG::DataProxy* proxy1 (bool nothrow) const;
417
418
426
427
438 bool tryRemap (sgkey_t& sgkey, size_t& index);
439
440
444};
445
446
447} // namespace SG
448
449
451
452
453#endif // not ATHLINKS_DATAPROXYHOLDER_H
uint32_t CLID
The Class ID type.
bool toPersistent(sgkey_t &sgkey, uint64_t &index)
Prepare this link for writing.
SG::DataProxy * m_proxy
The DataProxy referring to our object, if the LSB is clear; pointer to the object which we're referen...
DataProxyHolder(const DataProxyHolder &other, FROM_STORABLE *, TO_STORABLE *)
Constructor from a holder referencing a different type.
bool isObjpointer() const
Test to see if we're pointing directly at an object.
SG::DataProxy * proxy1(bool nothrow) const
Helper for proxy(), for the case of a direct object pointer.
sgkey_t toIdentifiedObject(const ID_type &dataID, CLID link_clid, IProxyDict *sg)
Set the link to an object given by a string key.
bool operator==(const DataProxyHolder &other) const
Compare for equality.
SG::sgkey_t sgkey_t
Type of hashed keys.
sgkey_t toStorableObject(const_pointer_t obj, CLID link_clid, IProxyDict *sg)
Set the link to an object given by a pointer.
void toPersistentNoRemap(sgkey_t &sgkey)
Prepare this link for writing.
IProxyDict * source1()
Return the data source for this reference.
pointer_t objpointer() const
Return a pointer to the object we're pointing at directly.
static bool thin(sgkey_t &sgkey, size_t &index, const SG::ThinningCache *thinningCache)
Adjust for thinning, with explicitly provided thinning cache.
void throwInvalidLink(sgkey_t sgkey) const
Throw a ExcInvalidLink exception for this link.
void storeObjpointer(const_pointer_t p)
Store a direct pointer to an object.
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
void * pointer_t
Generic pointer type.
bool tryRemap(sgkey_t &sgkey, size_t &index)
Test to see if the link has been remapped.
bool isDefault() const
Test to see if this is a null link.
bool toPersistent(sgkey_t &sgkey, const T &)
Prepare this link for writing.
DataProxyHolder(const DataProxyHolder &)=default
void * storableBase(castfn_t *castfn, CLID clid, bool isConst) const
Return a pointer to the currently-referenced object.
SG::DataProxy * proxy(bool nothrow=false) const
Return the DataProxy for this link.
DataProxyHolder & operator=(const DataProxyHolder &)=default
std::string ID_type
Type of string keys.
DataProxyHolder()
Default constructor.
IProxyDict * source() const
Return the data source for this reference.
const ID_type & dataID() const
Return the SG key that we reference, as a string.
void clear()
Reset the link to null.
void toTransient(sgkey_t sgkey, IProxyDict *sg=0)
Finish initialization after link has been read.
const void * const_pointer_t
Cache thinning decisions for converters.
Forward declaration.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
Definition index.py:1