ATLAS Offline Software
GenericElementLinkBase.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-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
15 #ifndef ATHLINKS_GENERICELEMENTLINKBASE_H
16 #define ATHLINKS_GENERICELEMENTLINKBASE_H
17 
18 
20 #include "AthLinks/tools/selection_ns.h"
21 #include "AthLinks/DataLinkBase.h"
23 #include "CxxUtils/CachedValue.h"
25 #include <concepts>
26 
27 
28 // Forward declaration(s):
30 namespace SG {
31 template< class INDEXING_POLICY >
32 struct GenericElementLinkBase;
33 }
35 
36 
37 template <class POLICY>
39 
40 
41 namespace SG {
42 
43 
44 class ThinningCache;
45 
46 
75 template <class INDEXING_POLICY>
76 class GenericElementLinkBase
77 {
78 private:
80  typedef typename INDEXING_POLICY::ElementType ElementType;
81  typedef typename INDEXING_POLICY::ElementConstPointer ElementConstPointer;
82 
85 
86 
87 public:
90 
92  typedef typename INDEXING_POLICY::stored_index_type stored_index_type;
93 
96 
99 
101  typedef void* castfn_t (SG::DataProxy*);
102 
103 
104 public:
109  bool isDefaultIndex() const;
110 
111 
115  bool hasCachedElement() const;
116 
117 
121  bool isDefault() const;
122 
123 
127  index_type index() const;
128 
129 
135  const ID_type& dataID() const;
136 
137 
143  sgkey_t key() const;
144 
145 
149  IProxyDict* source() const;
150 
151 
161  const SG::DataProxy* proxy() const;
162 
163 
167  void reset ();
168 
169 
180  bool toTransient (IProxyDict* sg = 0);
181 
182 
195  bool toPersistent();
196 
197 
206  bool thin();
207 
208 
220 
221 
222 protected:
227 
228 
239  CLID link_clid,
240  const index_type& elemID,
241  IProxyDict* sg);
242 
243 
254  CLID link_clid,
255  const index_type& elemID,
256  IProxyDict* sg);
257 
258 
272  CLID link_clid,
273  const index_type& elemID,
274  const ElementType& elt,
275  IProxyDict* sg);
276 
277 
291  CLID link_clid,
292  const index_type& elemID,
293  const ElementType& elt,
294  IProxyDict* sg);
295 
296 
307  CLID link_clid,
308  const index_type& elemID,
309  IProxyDict* sg);
310 
311 
321  const index_type& elemID);
322 
323 
330  const index_type& index);
331 
332 
343  template <class OTHER_INDEXING_POLICY, class FROM_TRAITS, class TO_TRAITS>
345  FROM_TRAITS*, TO_TRAITS*);
346 
347 
350 
351 
363  void* storableBase (castfn_t* castfn, const CLID& clid, bool isConst) const;
364 
365 
384  CLID link_clid,
385  bool replace,
386  IProxyDict* sg);
387 
388 
405  CLID link_clid,
406  const index_type& elemID,
407  IProxyDict* sg);
408 
409 
422  CLID link_clid,
423  const index_type& elemID,
424  IProxyDict* sg);
425 
426 
439  CLID link_clid,
440  const index_type& elemID,
441  IProxyDict* sg);
442 
443 
448  void setIndex (const index_type& index);
449 
450 
455 
456 
461  void setCachedElement (const ElementType& elt) const;
462 
463 
468  void storeCachedElement (const ElementType& elt);
469 
470 
479 
480 
485 
486 
487 private:
502  template <class INDEX>
503  requires (std::convertible_to<INDEX, size_t> &&
504  std::convertible_to<size_t, INDEX>)
505  bool thin1 (INDEX& persIndex,const SG::ThinningCache* thinningCache);
506 
507 
521  template <class INDEX>
522  requires (!(std::convertible_to<INDEX, size_t> &&
523  std::convertible_to<size_t, INDEX>))
524  bool thin1 (INDEX& persIndex,const SG::ThinningCache* thinningCache);
525 
526 
527  template <class OTHER_POLICY>
529 
531  template <class POLICY>
532  friend class ::ElementLinkBaseT_test;
533 
536 
539 
542 
545 
546 
548  typedef typename
550 };
551 
552 
553 } // namespace SG
554 
555 
558 namespace SG {
559 template <class INDEXING_POLICY>
560 struct GenericElementLinkBase : SelectNoInstance {
565 };
566 
567 }
569 
570 
572 
573 
574 #endif // not ATHLINKS_GENERICELEMENTLINKBASE_H
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(sgkey_t key, CLID link_clid, const index_type &elemID, const ElementType &elt, IProxyDict *sg)
Construct a link from a hashed key, index, AND pointer to element.
SG::GenericElementLinkBase::thin
bool thin(const SG::ThinningCache *thinningCache)
Adjust for thinning.
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SG::GenericElementLinkBase::key
sgkey_t key() const
Return the SG key that we reference, as a hash.
SG::GenericElementLinkBase::m_proxy
ROOT_SELECTION_NS::TRANSIENT m_proxy
Definition: GenericElementLinkBase.h:562
SG::GenericElementLinkBase::operator=
GenericElementLinkBase & operator=(const GenericElementLinkBase &)=default
SG::GenericElementLinkBase::proxy
const SG::DataProxy * proxy() const
Return the SG proxy for the container holding this element.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::GenericElementLinkBase::thinningCache
const SG::ThinningCache * thinningCache
Definition: GenericElementLinkBase.h:505
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase()
Default constructor.
SG::GenericElementLinkBase::resetWithKeyAndIndex
void resetWithKeyAndIndex(sgkey_t key, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Set the link to an element given by string key and index.
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(const DataLinkBase &dlink, const index_type &index)
Construct a link from a DataLink and an index.
index
Definition: index.py:1
SG::GenericElementLinkBase::storedIndex
const stored_index_type & storedIndex() const
Return the stored representation of the link index.
SG::GenericElementLinkBase::source
IProxyDict * source() const
Return the data source for this reference.
SG::GenericElementLinkBase::toTransient
bool toTransient(IProxyDict *sg=0)
Finish initialization after link has been read.
DataProxyHolder.h
Manage DataProxy reference in ElementLink/DataLink.
taskman.template
dictionary template
Definition: taskman.py:317
SG::GenericElementLinkBase::proxyHolder
const SG::DataProxyHolder & proxyHolder() const
Return the internal proxy holder object.
SG::GenericElementLinkBase::storableBase
void * storableBase(castfn_t *castfn, const CLID &clid, bool isConst) const
Return a pointer to the currently-referenced container object.
SG::GenericElementLinkBase::setIndex
void setIndex(const index_type &index)
Set the index part of the link.
SG::GenericElementLinkBase::hasCachedElement
bool hasCachedElement() const
Test to see if this link has a cached element pointer.
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::GenericElementLinkBase::index
index_type index() const
Return the index of the link.
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::GenericElementLinkBase::m_proxy
SG::DataProxyHolder m_proxy
SG proxy for this link.
Definition: GenericElementLinkBase.h:541
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(const_pointer_t obj, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Construct a link from an index and pointer to the container.
SG::GenericElementLinkBase::isDefaultIndex
bool isDefaultIndex() const
Test the index validity.
SG::GenericElementLinkBase::ID_type
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
Definition: GenericElementLinkBase.h:98
SG::GenericElementLinkBase
Generic base class for ElementLinks.
Definition: AthLinks/DataLinkBase.h:24
SG::GenericElementLinkBase::thin
bool thin()
Adjust for thinning.
SG::GenericElementLinkBase::const_pointer_t
SG::DataProxyHolder::const_pointer_t const_pointer_t
Generic pointer to the container (storable).
Definition: GenericElementLinkBase.h:84
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(const GenericElementLinkBase &)=default
SG::GenericElementLinkBase::index_type
INDEXING_POLICY::index_type index_type
The index type presented to and returned from the link.
Definition: GenericElementLinkBase.h:89
SG::GenericElementLinkBase::sgkey_t
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
Definition: GenericElementLinkBase.h:95
SG::DataProxyHolder
Manage DataProxy reference in ElementLink/DataLink.
Definition: DataProxyHolder.h:61
SG::GenericElementLinkBase::setCachedElement
void setCachedElement(const ElementType &elt) const
Set the cached element stored in the link.
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(const ID_type &dataID, CLID link_clid, const index_type &elemID, const ElementType &elt, IProxyDict *sg)
Construct a link from a string key, index, AND pointer to element.
CxxUtils
Definition: aligned_vector.h:29
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(const ID_type &dataID, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Construct a link from a string key and an index.
getThinningCache.h
Helpers to retrieve the current thinning cache from the event context.
SG::GenericElementLinkBase::m_index
stored_index_type m_index
The index of the element within the container for this link.
Definition: GenericElementLinkBase.h:538
SG::GenericElementLinkBase::storeCachedElement
void storeCachedElement(const ElementType &elt)
Set the cached element stored in the link.
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::GenericElementLinkBase::stored_index_type
INDEXING_POLICY::stored_index_type stored_index_type
The type of the index as it is stored internally.
Definition: GenericElementLinkBase.h:92
CachedValue.h
Cached value with atomic update.
SG::GenericElementLinkBase::ElementConstPointer
INDEXING_POLICY::ElementConstPointer ElementConstPointer
Definition: GenericElementLinkBase.h:81
SG::GenericElementLinkBase::toPersistent
bool toPersistent()
Prepare this link for writing.
SG::GenericElementLinkBase::m_element
CxxUtils::CachedValue< ElementType > m_element
Transient.
Definition: GenericElementLinkBase.h:544
SG::GenericElementLinkBase::isDefault
bool isDefault() const
Test to see if this link is in the default state.
SG::GenericElementLinkBase::getCachedElement
bool getCachedElement(ElementConstPointer &elt) const
Retrieve the cached element from the link.
python.Dumpers.typename
def typename(t)
Definition: Dumpers.py:194
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(const GenericElementLinkBase< OTHER_INDEXING_POLICY > &other, FROM_TRAITS *, TO_TRAITS *)
Constructor from a link referencing a different type.
ElementLinkBaseT_test
Definition: GenericElementLinkBase.h:38
SG::GenericElementLinkBase::setStorableObject
bool setStorableObject(const_pointer_t data, CLID link_clid, bool replace, IProxyDict *sg)
Set the container referenced by the link to data.
SG::GenericElementLinkBase::dataID
const ID_type & dataID() const
Return the SG key that we reference, as a string.
SG::GenericElementLinkBase::m_key
SG::sgkey_t m_key
The hashed key for this link.
Definition: GenericElementLinkBase.h:535
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(const GenericElementLinkBase &other, const index_type &elemID)
Construct a link from another link, changing the index.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::DataProxyHolder::const_pointer_t
const void * const_pointer_t
Definition: DataProxyHolder.h:71
SG::GenericElementLinkBase::m_element
ROOT_SELECTION_NS::TRANSIENT m_element
Definition: GenericElementLinkBase.h:564
SG::GenericElementLinkBase::GenericElementLinkBase
GenericElementLinkBase(sgkey_t key, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Construct a link from a hashed key and an index.
SG::DataProxyHolder::sgkey_t
IStringPool::sgkey_t sgkey_t
Type of hashed keys.
Definition: DataProxyHolder.h:64
SG::GenericElementLinkBase::resetWithKeyAndIndex
void resetWithKeyAndIndex(const ID_type &dataID, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Set the link to an element given by string key and index.
GenericElementLinkBase.icc
SG::GenericElementLinkBase::reset
void reset()
Reset the link to a null state.
checker_macros.h
Define macros for attributes used to control the static checker.
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::GenericElementLinkBase::requires
requires(std::convertible_to< INDEX, size_t > &&std::convertible_to< size_t, INDEX >) bool thin1(INDEX &persIndex
Adjust for thinning.
SG::GenericElementLinkBase::m_cacheValid
ROOT_SELECTION_NS::TRANSIENT m_cacheValid
Definition: GenericElementLinkBase.h:563
SG::DataProxy
Definition: DataProxy.h:44
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
SG::ThinningCache
Cache thinning decisions for converters.
Definition: ThinningCache.h:48
SG::GenericElementLinkBase::ElementType
INDEXING_POLICY::ElementType ElementType
Generic pointer to an element.
Definition: GenericElementLinkBase.h:80
SG::GenericElementLinkBase::toIndexedElement
bool toIndexedElement(const_pointer_t obj, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Set the to an element given by index and pointer to container.
SG::GenericElementLinkBase::castfn_t
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
Definition: GenericElementLinkBase.h:101
DataLinkBase
Type-independent part of DataLink; holds the persistent state.
Definition: AthLinks/DataLinkBase.h:37
SG::DataProxyHolder::ID_type
std::string ID_type
Type of string keys.
Definition: DataProxyHolder.h:67
index_type
unsigned int index_type
Definition: FPGATrackSimSGToRawHitsTool.h:37
SG::GenericElementLinkBase::DictSel
ROOT_SELECTION_NS::SG::GenericElementLinkBase< INDEXING_POLICY >::self DictSel
Transient.
Definition: GenericElementLinkBase.h:549