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"
25#include <concepts>
26#include <RootMetaSelection.h>
27
28
29// Forward declaration(s):
30namespace ROOT { namespace Meta { namespace Selection {
31 namespace SG {
32 template< class INDEXING_POLICY >
34 }
35}}}
36
37
38template <class POLICY>
40
41
42namespace SG {
43
44
45class ThinningCache;
46
47
76template <class INDEXING_POLICY>
78{
79private:
81 typedef typename INDEXING_POLICY::ElementType ElementType;
82 typedef typename INDEXING_POLICY::ElementConstPointer ElementConstPointer;
83
86
87
88public:
90 typedef typename INDEXING_POLICY::index_type index_type;
91
93 typedef typename INDEXING_POLICY::stored_index_type stored_index_type;
94
97
100
102 typedef void* castfn_t (SG::DataProxy*);
103
104
105public:
110 bool isDefaultIndex() const;
111
112
116 bool hasCachedElement() const;
117
118
122 bool isDefault() const;
123
124
129
130
136 const ID_type& dataID() const;
137
138
144 sgkey_t key() const;
145
146
151
152
162 const SG::DataProxy* proxy() const;
163
164
168 void reset ();
169
170
181 bool toTransient (IProxyDict* sg = 0);
182
183
197
198
207 bool thin();
208
209
220 bool thin (const SG::ThinningCache* thinningCache);
221
222
223protected:
228
229
240 CLID link_clid,
241 const index_type& elemID,
242 IProxyDict* sg);
243
244
255 CLID link_clid,
256 const index_type& elemID,
257 IProxyDict* sg);
258
259
273 CLID link_clid,
274 const index_type& elemID,
275 const ElementType& elt,
276 IProxyDict* sg);
277
278
292 CLID link_clid,
293 const index_type& elemID,
294 const ElementType& elt,
295 IProxyDict* sg);
296
297
308 CLID link_clid,
309 const index_type& elemID,
310 IProxyDict* sg);
311
312
322 const index_type& elemID);
323
324
331 const index_type& index);
332
333
344 template <class OTHER_INDEXING_POLICY, class FROM_TRAITS, class TO_TRAITS>
346 FROM_TRAITS*, TO_TRAITS*);
347
348
351
352
364 void* storableBase (castfn_t* castfn, const CLID& clid, bool isConst) const;
365
366
385 CLID link_clid,
386 bool replace,
387 IProxyDict* sg);
388
389
406 CLID link_clid,
407 const index_type& elemID,
408 IProxyDict* sg);
409
410
423 CLID link_clid,
424 const index_type& elemID,
425 IProxyDict* sg);
426
427
440 CLID link_clid,
441 const index_type& elemID,
442 IProxyDict* sg);
443
444
449 void setIndex (const index_type& index);
450
451
456
457
462 void setCachedElement (const ElementType& elt) const;
463
464
470
471
480
481
486
487
488private:
503 template <class INDEX>
504 requires (std::convertible_to<INDEX, size_t> &&
505 std::convertible_to<size_t, INDEX>)
506 bool thin1 (INDEX& persIndex,const SG::ThinningCache* thinningCache);
507
508
522 template <class INDEX>
523 requires (!(std::convertible_to<INDEX, size_t> &&
524 std::convertible_to<size_t, INDEX>))
525 bool thin1 (INDEX& persIndex,const SG::ThinningCache* thinningCache);
526
527
528 template <class OTHER_POLICY>
530
532 template <class POLICY>
533 friend class ::ElementLinkBaseT_test;
534
537
540
543
546
547
549 typedef typename
551};
552
553
554} // namespace SG
555
556
558namespace ROOT { namespace Meta { namespace Selection {
559namespace SG {
560template <class INDEXING_POLICY>
561struct GenericElementLinkBase : SelectNoInstance {
563 ROOT::Meta::Selection::MemberAttributes<kTransient> m_proxy;
564 ROOT::Meta::Selection::MemberAttributes<kTransient> m_cacheValid;
565 ROOT::Meta::Selection::MemberAttributes<kTransient> m_element;
566};
567
568}
569}}} // ROOT namespace
570
571
573namespace SG {
574
575
576template <class INDEXING_POLICY>
578{
579 el.toTransient (sg);
580 return true;
581}
582
583
584template <class INDEXING_POLICY>
585bool toTransient (GenericElementLinkBase<INDEXING_POLICY>& el, const EventContext& ctx)
586{
587 el.toTransient (Atlas::proxyDictFromEventContext (ctx));
588 return true;
589}
590
591
592} // namespace SG
593
594
595
596
597#endif // not ATHLINKS_GENERICELEMENTLINKBASE_H
Cached value with atomic update.
Manage DataProxy reference in ElementLink/DataLink.
uint32_t CLID
The Class ID type.
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
Generic base class for ElementLinks.
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:312
IProxyDict * proxyDictFromEventContext()
Return the IProxyDict for this thread's current context.
Selection rules: declare transient members.
Definition DataVector.h:583
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.
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