ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14
15#ifndef ATHLINKS_GENERICELEMENTLINKBASE_H
16#define ATHLINKS_GENERICELEMENTLINKBASE_H
17
18
20#include "AthLinks/DataLinkBase.h"
24#include <concepts>
25#include <RootMetaSelection.h>
26
27
28// Forward declaration(s):
29namespace ROOT { namespace Meta { namespace Selection {
30 namespace SG {
31 template< class INDEXING_POLICY >
33 }
34}}}
35
36
37template <class POLICY>
39
40
41namespace SG {
42
43
44class ThinningCache;
45
46
75template <class INDEXING_POLICY>
77{
78private:
80 typedef typename INDEXING_POLICY::ElementType ElementType;
81 typedef typename INDEXING_POLICY::ElementConstPointer ElementConstPointer;
82
85
86
87public:
89 typedef typename INDEXING_POLICY::index_type index_type;
90
92 typedef typename INDEXING_POLICY::stored_index_type stored_index_type;
93
96
99
101 typedef void* castfn_t (SG::DataProxy*);
102
103
104public:
109 bool isDefaultIndex() const;
110
111
115 bool hasCachedElement() const;
116
117
121 bool isDefault() const;
122
123
128
129
135 const ID_type& dataID() const;
136
137
143 sgkey_t key() const;
144
145
150
151
161 const SG::DataProxy* proxy() const;
162
163
167 void reset ();
168
169
180 bool toTransient (IProxyDict* sg = 0);
181
182
196
197
206 bool thin();
207
208
219 bool thin (const SG::ThinningCache* thinningCache);
220
221
222protected:
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
469
470
479
480
485
486
487private:
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
557namespace ROOT { namespace Meta { namespace Selection {
558namespace SG {
559template <class INDEXING_POLICY>
560struct GenericElementLinkBase : SelectNoInstance {
562 ROOT::Meta::Selection::MemberAttributes<kTransient> m_proxy;
563 ROOT::Meta::Selection::MemberAttributes<kTransient> m_cacheValid;
564 ROOT::Meta::Selection::MemberAttributes<kTransient> m_element;
565};
566
567}
568}}} // ROOT namespace
569
570
572
573
574#endif // not ATHLINKS_GENERICELEMENTLINKBASE_H
Cached value with atomic update.
Manage DataProxy reference in ElementLink/DataLink.
uint32_t CLID
The Class ID type.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Define macros for attributes used to control the static checker.
Cached value with atomic update.
Definition CachedValue.h:55
Type-independent part of DataLink; holds the persistent state.
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
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
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.
GenericElementLinkBase & operator=(const GenericElementLinkBase &)=default
bool toTransient(IProxyDict *sg=0)
Finish initialization after link has been read.
bool isDefault() const
Test to see if this link is in the default state.
IProxyDict * source() const
Return the data source for this reference.
bool thin()
Adjust for thinning.
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.
void storeCachedElement(const ElementType &elt)
Set the cached element stored in the link.
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.
GenericElementLinkBase(const DataLinkBase &dlink, const index_type &index)
Construct a link from a DataLink and an index.
void reset()
Reset the link to a null state.
const SG::DataProxyHolder & proxyHolder() const
Return the internal proxy holder object.
INDEXING_POLICY::index_type index_type
The index type presented to and returned from the link.
index_type index() const
Return the index of the link.
GenericElementLinkBase(const ID_type &dataID, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Construct a link from a string key and an index.
void setCachedElement(const ElementType &elt) const
Set the cached element stored in the link.
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
INDEXING_POLICY::ElementType ElementType
Generic pointer to an element.
SG::DataProxyHolder::const_pointer_t const_pointer_t
Generic pointer to the container (storable).
bool isDefaultIndex() const
Test the index validity.
GenericElementLinkBase()
Default constructor.
ROOT::Meta::Selection::SG::GenericElementLinkBase< INDEXING_POLICY >::self DictSel
Transient.
INDEXING_POLICY::ElementConstPointer ElementConstPointer
const ID_type & dataID() const
Return the SG key that we reference, as a string.
const stored_index_type & storedIndex() const
Return the stored representation of the link index.
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.
bool thin(const SG::ThinningCache *thinningCache)
Adjust for thinning.
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.
GenericElementLinkBase(const GenericElementLinkBase< OTHER_INDEXING_POLICY > &other, FROM_TRAITS *, TO_TRAITS *)
Constructor from a link referencing a different type.
GenericElementLinkBase(const GenericElementLinkBase &)=default
bool setStorableObject(const_pointer_t data, CLID link_clid, bool replace, IProxyDict *sg)
Set the container referenced by the link to data.
INDEXING_POLICY::stored_index_type stored_index_type
The type of the index as it is stored internally.
const SG::DataProxy * proxy() const
Return the SG proxy for the container holding this element.
bool toPersistent()
Prepare this link for writing.
GenericElementLinkBase(const GenericElementLinkBase &other, const index_type &elemID)
Construct a link from another link, changing the index.
bool hasCachedElement() const
Test to see if this link has a cached element pointer.
bool getCachedElement(ElementConstPointer &elt) const
Retrieve the cached element from the link.
CxxUtils::CachedValue< ElementType > m_element
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.
bool thin1(INDEX &persIndex, const SG::ThinningCache *thinningCache)
void * storableBase(castfn_t *castfn, const CLID &clid, bool isConst) const
Return a pointer to the currently-referenced container object.
GenericElementLinkBase(sgkey_t key, CLID link_clid, const index_type &elemID, IProxyDict *sg)
Construct a link from a hashed key and an index.
sgkey_t key() const
Return the SG key that we reference, as a hash.
void setIndex(const index_type &index)
Set the index part of the link.
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
Selection rules: declare transient members.
Definition DataVector.h:581
Forward declaration.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
Definition index.py:1
ROOT::Meta::Selection::MemberAttributes< kTransient > m_cacheValid
ROOT::Meta::Selection::MemberAttributes< kTransient > m_proxy
ROOT::Meta::Selection::MemberAttributes< kTransient > m_element
GenericElementLinkBase< INDEXING_POLICY > self