ATLAS Offline Software
Loading...
Searching...
No Matches
AthLinks/ElementLinkBase.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_ELEMENTLINKBASE_H
15#define ATHLINKS_ELEMENTLINKBASE_H
16
17
20#include "AthLinks/DataLinkBase.h"
24#include "SGCore/sgkey_t.h"
26#include <cstdlib>
27#include <stdint.h>
28
29
30namespace SG {
31 class ThinningCache;
32}
33
34
61{
62private:
64 static const uint32_t INVALID = static_cast<uint32_t> (-1);
65
67 typedef const void* ElementType;
68
71
72
73public:
75 typedef size_t index_type;
76
78 typedef uint32_t stored_index_type;
79
82
85
87 typedef void* castfn_t (SG::DataProxy*);
88
89
90 ElementLinkBase (const ElementLinkBase&) = default;
92
93
98 bool isDefaultIndex() const;
99
100
104 bool hasCachedElement() const;
105
106
110 bool isDefault() const;
111
112
117
118
124
125
131 const ID_type& dataID() const;
132
133
139 sgkey_t key() const;
140
141
148 sgkey_t persKey() const;
149
150
155
156
166 const SG::DataProxy* proxy() const;
167
168
172 void reset ();
173
174
185 bool toTransient (IProxyDict* sg = 0);
186
187
201
202
211 bool thin();
212
213
224 bool thin (const SG::ThinningCache* thinningCache);
225
226
233
234
235protected:
246 CLID link_clid,
247 index_type elemID,
248 IProxyDict* sg);
249
250
261 CLID link_clid,
262 index_type elemID,
263 IProxyDict* sg);
264
265
266
280 CLID link_clid,
281 index_type elemID,
282 const void* elt,
283 IProxyDict* sg);
284
285
299 CLID link_clid,
300 index_type elemID,
301 const void* elt,
302 IProxyDict* sg);
303
304
315 CLID link_clid,
316 index_type elemID,
317 IProxyDict* sg);
318
319
329
330
337
338
349 template <class FROM_TRAITS, class TO_TRAITS>
351 FROM_TRAITS*, TO_TRAITS*);
352
353
365 void* storableBase (castfn_t* castfn, CLID clid, bool isConst) const;
366
367
386 CLID link_clid,
387 bool replace,
388 IProxyDict* sg);
389
390
407 CLID link_clid,
408 index_type elemID,
409 IProxyDict* sg);
410
411
424 CLID link_clid,
425 index_type elemID,
426 IProxyDict* sg);
427
428
441 CLID link_clid,
442 index_type elemID,
443 IProxyDict* sg);
444
445
451
452
457
458
469
470
476
477
485 template <class T>
486 bool getCachedElement (const T* & elt) const;
487
488
493
494
495private:
498
501
504
507
510
512};
513
514
515namespace SG {
516
517
518inline
520{
521 el.toTransient (sg);
522 return true;
523}
524
525
526inline
527bool toTransient (ElementLinkBase& el, const EventContext& ctx)
528{
529 el.toTransient (Atlas::proxyDictFromEventContext (ctx));
530 return true;
531}
532
533
534} // namespace SG
535
536
538
539
540#endif // not ATHLINKS_ELEMENTLINKBASE_H
Cached pointer with atomic update.
Manage DataProxy reference in ElementLink/DataLink.
uint32_t CLID
The Class ID type.
Indexing policy for a vector-like container.
Define a hook for running code after an object has been read.
Type-independent part of DataLink; holds the persistent state.
Base class for ElementLinks to vectors of pointers.
ElementLinkBase(sgkey_t key, CLID link_clid, index_type elemID, const void *elt, IProxyDict *sg)
Construct a link from a hashed key, index, AND pointer to element.
bool isDefault() const
Test to see if this link is in the default state.
friend class ElementLinkBase_test
For regression testing.
ElementLinkBase(const ElementLinkBase &other, index_type elemID)
Construct a link from another link, changing the index.
bool toIndexedElement(const_pointer_t obj, CLID link_clid, index_type elemID, IProxyDict *sg)
Set the link to an element given by index and pointer to container.
const SG::DataProxy * proxy() const
Return the SG proxy for the container holding this element.
bool isDefaultIndex() const
Test the index validity.
void clearCachedElement()
Clear the currently-cached element.
ElementLinkBase(const_pointer_t obj, CLID link_clid, index_type elemID, IProxyDict *sg)
Construct a link from an index and pointer to the container.
ElementLinkBase & operator=(const ElementLinkBase &)=default
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
void resetWithKeyAndIndex(const ID_type &dataID, CLID link_clid, index_type elemID, IProxyDict *sg)
Set the link to an element given by string key and index.
void * storableBase(castfn_t *castfn, CLID clid, bool isConst) const
Return a pointer to the currently-referenced container object.
const void * ElementType
Generic pointer to an element.
CxxUtils::CachedPointer< void > m_element
Transient.
bool thin()
Adjust for thinning.
stored_index_type persIndex() const
Return the index of the link.
sgkey_t key() const
Return the SG key that we reference, as a hash.
ElementLinkBase(const ElementLinkBase &other, FROM_TRAITS *, TO_TRAITS *)
Constructor from a link referencing a different type.
ElementLinkBase(const ID_type &dataID, CLID link_clid, index_type elemID, IProxyDict *sg)
Construct a link from a string key and an index.
stored_index_type m_persIndex
The index of the element within the container for this link.
bool toPersistent()
Prepare this link for writing.
void setCachedElement(ElementType elt) const
Set the cached element stored in the link, assuming the cached element is null.
void setIndex(index_type index)
Set the index part of the link.
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
SG::DataProxyHolder m_proxy
SG proxy for this link.
uint32_t stored_index_type
The type of the index as it is stored internally.
sgkey_t persKey() const
Return the SG key that we reference, as a hash.
ElementLinkBase(sgkey_t key, CLID link_clid, index_type elemID, IProxyDict *sg)
Construct a link from a hashed key and an index.
ElementLinkBase(const ID_type &dataID, CLID link_clid, index_type elemID, const void *elt, IProxyDict *sg)
Construct a link from a string key, index, AND pointer to element.
size_t index_type
The index type presented to and returned from the link.
ElementLinkBase()
Default constructor.
static const uint32_t INVALID
Value to mark an invalid index.
IProxyDict * source() const
Return the data source for this reference.
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
const ID_type & dataID() const
Return the SG key that we reference, as a string.
index_type index() const
Return the index of the link.
bool getCachedElement(const T *&elt) const
Retrieve the cached element from the link.
bool thin(const SG::ThinningCache *thinningCache)
Adjust for thinning.
const stored_index_type & storedIndex() const
Return the stored representation of the link index.
SG::sgkey_t m_persKey
The hashed key for this link.
void resetWithKeyAndIndex(sgkey_t key, CLID link_clid, index_type elemID, IProxyDict *sg)
Set the link to an element given by string key and index.
const SG::DataProxyHolder & proxyHolder() const
Return the internal proxy holder object.
ElementLinkBase(const DataLinkBase &dlink, index_type index)
Construct a link from a DataLink and an index.
void reset()
Reset the link to a null state.
bool setStorableObject(const_pointer_t data, CLID link_clid, bool replace, IProxyDict *sg)
Set the container referenced by the link to data.
bool hasCachedElement() const
Test to see if this link has a cached element pointer.
void storeCachedElement(ElementType elt)
Set the cached element stored in the link.
SG::DataProxyHolder::const_pointer_t const_pointer_t
Generic pointer to the container (storable).
ElementLinkBase(const ElementLinkBase &)=default
bool toTransient(IProxyDict *sg=0)
Finish initialization after link has been read.
Manage DataProxy reference in ElementLink/DataLink.
SG::sgkey_t sgkey_t
Type of hashed keys.
std::string ID_type
Type of string keys.
const void * const_pointer_t
Cache thinning decisions for converters.
Helpers to retrieve the current thinning cache from the event context.
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312
IProxyDict * proxyDictFromEventContext()
Return the IProxyDict for this thread's current context.
Forward declaration.
void toTransient(const EventContext &ctx, SG::auxid_t auxid)
Perform post-read processing for a single variable.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
Definition index.py:1
Some out-of-line helpers for ExtendedEventContext.
Cached pointer with atomic update.