ATLAS Offline Software
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-2023 CERN for the benefit of the ATLAS collaboration
5 */
14 #ifndef ATHLINKS_ELEMENTLINKBASE_H
15 #define ATHLINKS_ELEMENTLINKBASE_H
16 
17 
20 #include "AthLinks/DataLinkBase.h"
22 #include "CxxUtils/sgkey_t.h"
23 #include "CxxUtils/CachedPointer.h"
24 #include <cstdlib>
25 #include <stdint.h>
26 
27 
28 namespace SG {
29  class ThinningCache;
30 }
31 
32 
59 {
60 private:
62  static const uint32_t INVALID = static_cast<uint32_t> (-1);
63 
65  typedef const void* ElementType;
66 
69 
70 
71 public:
73  typedef size_t index_type;
74 
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 
114  index_type index() const;
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 
152  IProxyDict* source() const;
153 
154 
164  const SG::DataProxy* proxy() const;
165 
166 
170  void reset ();
171 
172 
183  bool toTransient (IProxyDict* sg = 0);
184 
185 
198  bool toPersistent();
199 
200 
209  bool thin();
210 
211 
222  bool thin (const SG::ThinningCache* thinningCache);
223 
224 
231 
232 
233 protected:
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 
466  void setCachedElement (ElementType elt) const;
467 
468 
474 
475 
483  template <class T>
484  bool getCachedElement (const T* & elt) const;
485 
486 
491 
492 
493 private:
495  friend class ElementLinkBase_test;
496 
499 
502 
505 
508 
510 };
511 
512 
514 
515 
516 #endif // not ATHLINKS_ELEMENTLINKBASE_H
ElementLinkBase::const_pointer_t
SG::DataProxyHolder::const_pointer_t const_pointer_t
Generic pointer to the container (storable).
Definition: AthLinks/ElementLinkBase.h:68
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
ElementLinkBase::proxyHolder
const SG::DataProxyHolder & proxyHolder() const
Return the internal proxy holder object.
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
ElementLinkBase::storeCachedElement
void storeCachedElement(ElementType elt)
Set the cached element stored in the link.
ElementLinkBase::ElementLinkBase
ElementLinkBase(const ID_type &dataID, CLID link_clid, index_type elemID, IProxyDict *sg)
Construct a link from a string key and an index.
ElementLinkBase::reset
void reset()
Reset the link to a null state.
ElementLinkBase::operator=
ElementLinkBase & operator=(const ElementLinkBase &)=default
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
ElementLinkBase::storedIndex
const stored_index_type & storedIndex() const
Return the stored representation of the link index.
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
ElementLinkBase::toIndexedElement
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.
ElementLinkBase::resetWithKeyAndIndex
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.
ElementLinkBase::persIndex
stored_index_type persIndex() const
Return the index of the link.
Definition: ElementLinkBase.cxx:31
DataProxyHolder.h
Manage DataProxy reference in ElementLink/DataLink.
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
CachedPointer.h
Cached pointer with atomic update.
ElementLinkBase::thin
bool thin(const SG::ThinningCache *thinningCache)
Adjust for thinning.
ElementLinkBase
Base class for ElementLinks to vectors of pointers.
Definition: AthLinks/ElementLinkBase.h:59
ElementLinkBase::persKey
sgkey_t persKey() const
Return the SG key that we reference, as a hash.
Definition: ElementLinkBase.cxx:13
ElementLinkBase::ElementLinkBase
ElementLinkBase(const DataLinkBase &dlink, index_type index)
Construct a link from a DataLink and an index.
ElementLinkBase::ElementLinkBase
ElementLinkBase(const ElementLinkBase &)=default
ElementLinkBase::ElementLinkBase
ElementLinkBase(sgkey_t key, CLID link_clid, index_type elemID, IProxyDict *sg)
Construct a link from a hashed key and an index.
ElementLinkBase::ElementType
const void * ElementType
Generic pointer to an element.
Definition: AthLinks/ElementLinkBase.h:65
ElementLinkBase::hasCachedElement
bool hasCachedElement() const
Test to see if this link has a cached element pointer.
ForwardIndexingPolicy.h
Indexing policy for a vector-like container.
ElementLinkBase::toTransient
bool toTransient(IProxyDict *sg=0)
Finish initialization after link has been read.
ElementLinkBase::stored_index_type
uint32_t stored_index_type
The type of the index as it is stored internally.
Definition: AthLinks/ElementLinkBase.h:76
ElementLinkBase::clearCachedElement
void clearCachedElement()
Clear the currently-cached element.
ElementLinkBase::sgkey_t
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
Definition: AthLinks/ElementLinkBase.h:79
ElementLinkBase::ElementLinkBase_test
friend class ElementLinkBase_test
For regression testing.
Definition: AthLinks/ElementLinkBase.h:495
ElementLinkBase::getCachedElement
bool getCachedElement(const T *&elt) const
Retrieve the cached element from the link.
SG::DataProxyHolder
Manage DataProxy reference in ElementLink/DataLink.
Definition: DataProxyHolder.h:61
ElementLinkBase.icc
getThinningCache.h
Helpers to retrieve the current thinning cache from the event context.
ElementLinkBase::ID_type
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
Definition: AthLinks/ElementLinkBase.h:82
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ElementLinkBase::setCachedElement
void setCachedElement(ElementType elt) const
Set the cached element stored in the link, assuming the cached element is null.
ElementLinkBase::INVALID
static const uint32_t INVALID
Value to mark an invalid index.
Definition: AthLinks/ElementLinkBase.h:62
ElementLinkBase::m_element
CxxUtils::CachedPointer< void > m_element
Transient.
Definition: AthLinks/ElementLinkBase.h:509
ElementLinkBase::dataID
const ID_type & dataID() const
Return the SG key that we reference, as a string.
ElementLinkBase::storableBase
void * storableBase(castfn_t *castfn, CLID clid, bool isConst) const
Return a pointer to the currently-referenced container object.
ElementLinkBase::ElementLinkBase
ElementLinkBase(const ElementLinkBase &other, index_type elemID)
Construct a link from another link, changing the index.
ElementLinkBase::m_proxy
SG::DataProxyHolder m_proxy
SG proxy for this link.
Definition: AthLinks/ElementLinkBase.h:507
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
ElementLinkBase::resetWithKeyAndIndex
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.
ElementLinkBase::source
IProxyDict * source() const
Return the data source for this reference.
ElementLinkBase::ElementLinkBase
ElementLinkBase()
Default constructor.
ElementLinkBase::ElementLinkBase
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.
ElementLinkBase::ElementLinkBase
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.
sgkey_t.h
Define the type used for hashed StoreGate key+CLID pairs.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
ElementLinkBase::setIndex
void setIndex(index_type index)
Set the index part of the link.
SG::DataProxyHolder::const_pointer_t
const void * const_pointer_t
Definition: DataProxyHolder.h:71
ElementLinkBase::castfn_t
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
Definition: AthLinks/ElementLinkBase.h:85
ElementLinkBase::toPersistent
bool toPersistent()
Prepare this link for writing.
CxxUtils::CachedPointer< void >
ElementLinkBase::key
sgkey_t key() const
Return the SG key that we reference, as a hash.
ElementLinkBase::ElementLinkBase
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::ElementLinkBase
ElementLinkBase(const ElementLinkBase &other, FROM_TRAITS *, TO_TRAITS *)
Constructor from a link referencing a different type.
SG::DataProxyHolder::sgkey_t
IStringPool::sgkey_t sgkey_t
Type of hashed keys.
Definition: DataProxyHolder.h:64
ElementLinkBase::m_persIndex
stored_index_type m_persIndex
The index of the element within the container for this link.
Definition: AthLinks/ElementLinkBase.h:504
python.PyAthena.obj
obj
Definition: PyAthena.py:132
ElementLinkBase::proxy
const SG::DataProxy * proxy() const
Return the SG proxy for the container holding this element.
SG::DataProxy
Definition: DataProxy.h:44
SG::ThinningCache
Cache thinning decisions for converters.
Definition: ThinningCache.h:48
ElementLinkBase::isDefaultIndex
bool isDefaultIndex() const
Test the index validity.
ElementLinkBase::setStorableObject
bool setStorableObject(const_pointer_t data, CLID link_clid, bool replace, IProxyDict *sg)
Set the container referenced by the link to data.
ElementLinkBase::isDefault
bool isDefault() const
Test to see if this link is in the default state.
Definition: ElementLinkBase.cxx:49
ElementLinkBase::thin
bool thin()
Adjust for thinning.
ElementLinkBase::m_persKey
SG::sgkey_t m_persKey
The hashed key for this link.
Definition: AthLinks/ElementLinkBase.h:501
DataLinkBase
Type-independent part of DataLink; holds the persistent state.
Definition: AthLinks/DataLinkBase.h:37
ElementLinkBase::index
index_type index() const
Return the index of the link.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
SG::DataProxyHolder::ID_type
std::string ID_type
Type of string keys.
Definition: DataProxyHolder.h:67
ElementLinkBase::index_type
size_t index_type
The index type presented to and returned from the link.
Definition: AthLinks/ElementLinkBase.h:73