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"
22#include "SGCore/sgkey_t.h"
24#include <cstdlib>
25#include <stdint.h>
26
27
28namespace SG {
29 class ThinningCache;
30}
31
32
59{
60private:
62 static const uint32_t INVALID = static_cast<uint32_t> (-1);
63
65 typedef const void* ElementType;
66
69
70
71public:
73 typedef size_t index_type;
74
76 typedef uint32_t stored_index_type;
77
80
83
85 typedef void* castfn_t (SG::DataProxy*);
86
87
88 ElementLinkBase (const ElementLinkBase&) = default;
90
91
96 bool isDefaultIndex() const;
97
98
102 bool hasCachedElement() const;
103
104
108 bool isDefault() const;
109
110
115
116
122
123
129 const ID_type& dataID() const;
130
131
137 sgkey_t key() const;
138
139
146 sgkey_t persKey() const;
147
148
153
154
164 const SG::DataProxy* proxy() const;
165
166
170 void reset ();
171
172
183 bool toTransient (IProxyDict* sg = 0);
184
185
199
200
209 bool thin();
210
211
222 bool thin (const SG::ThinningCache* thinningCache);
223
224
231
232
233protected:
244 CLID link_clid,
245 index_type elemID,
246 IProxyDict* sg);
247
248
259 CLID link_clid,
260 index_type elemID,
261 IProxyDict* sg);
262
263
264
278 CLID link_clid,
279 index_type elemID,
280 const void* elt,
281 IProxyDict* sg);
282
283
297 CLID link_clid,
298 index_type elemID,
299 const void* elt,
300 IProxyDict* sg);
301
302
313 CLID link_clid,
314 index_type elemID,
315 IProxyDict* sg);
316
317
327
328
335
336
347 template <class FROM_TRAITS, class TO_TRAITS>
349 FROM_TRAITS*, TO_TRAITS*);
350
351
363 void* storableBase (castfn_t* castfn, CLID clid, bool isConst) const;
364
365
384 CLID link_clid,
385 bool replace,
386 IProxyDict* sg);
387
388
405 CLID link_clid,
406 index_type elemID,
407 IProxyDict* sg);
408
409
422 CLID link_clid,
423 index_type elemID,
424 IProxyDict* sg);
425
426
439 CLID link_clid,
440 index_type elemID,
441 IProxyDict* sg);
442
443
449
450
455
456
467
468
474
475
483 template <class T>
484 bool getCachedElement (const T* & elt) const;
485
486
491
492
493private:
496
499
502
505
508
510};
511
512
514
515
516#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.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Type-independent part of DataLink; holds the persistent state.
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:310
Forward declaration.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
Definition index.py:1
Cached pointer with atomic update.