ATLAS Offline Software
Loading...
Searching...
No Matches
AthLinks/ElementLink.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 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
11
12
13#ifndef ATHLINKS_ELEMENTLINK_H
14#define ATHLINKS_ELEMENTLINK_H
15
16
18#include "AthLinks/DataLink.h"
21#include <format>
22#include <utility>
23#include <vector>
24
25
26class IProxyDict;
27class EventContext;
28
29
122template <class STORABLE>
123class ElementLink
124 : public SG::ElementLinkTraits<STORABLE>::Base
125{
126private:
128 typedef SG::ElementLinkTraits<STORABLE> Traits;
129
131 typedef typename Traits::Base Base;
132
134 typedef typename Base::castfn_t castfn_t;
135
136
137public:
139 typedef typename Traits::IndexingPolicy IndexingPolicy;
140
142 typedef typename IndexingPolicy::index_type index_type;
143
145 typedef typename Base::sgkey_t sgkey_t;
146
148 typedef typename Base::ID_type ID_type;
149
151 typedef STORABLE value_type;
152 typedef STORABLE* pointer;
153 typedef const STORABLE* const_pointer;
154 typedef const STORABLE& BaseConstReference;
155 typedef const STORABLE* BaseConstPointer;
156
157
159 typedef typename IndexingPolicy::ElementType ElementType;
160 typedef typename IndexingPolicy::ElementConstReference ElementConstReference;
161 typedef typename IndexingPolicy::ElementConstPointer ElementConstPointer;
162
163
167 static CLID classID();
168
169
170 //========================================================================
173
174
179
180
190 IProxyDict* sg = 0);
191
192
200 const EventContext& ctx);
201
202
212
213
220 ElementLink(sgkey_t key, index_type elemID, const EventContext& ctx);
221
222
235 index_type elemID,
236 ElementType pEl,
237 IProxyDict* sg = 0);
238
239
250 index_type elemID,
251 ElementType pEl,
252 const EventContext& ctx);
253
254
267 index_type elemID,
268 ElementType pEl,
269 IProxyDict* sg = 0);
270
271
282 index_type elemID,
283 ElementType pEl,
284 const EventContext& ctx);
285
286
296 index_type elemID,
297 IProxyDict* sg = 0);
298
299
307 index_type elemID,
308 const EventContext& ctx);
309
310
327 ElementLink (const ElementType& element,
329 IProxyDict* sg = 0);
330
331
346 ElementLink (const ElementType& element,
348 const EventContext& ctx);
349
350
359 ElementLink (const ElementLink& other, index_type elemID);
360
361
368
369
370 // Use default copy ctor.
371
372
376 template <class U>
378
379
380 // Default copy and assignment.
381 ElementLink (const ElementLink&) = default;
383
384
385 //@)
386 //========================================================================
389
390
396 const_pointer getDataPtr() const;
397
398
405
406
411
412
416 const DataLink<STORABLE> getDataLink() const;
417
418
423
424
429
430
438
439
446
447
452
453
457 operator ElementConstPointer () const;
458
459
466 bool isValid() const;
467
468
472 bool operator!() const;
473
474
479
480
481
482 //@)
483 //========================================================================
486
487
503 IProxyDict* sg = 0);
504
505
517 const EventContext& ctx);
518
519
537 ElementType element,
538 IProxyDict* sg = 0);
539
540
554 ElementType element,
555 const EventContext& ctx);
556
557
569 bool setElement(ElementType element);
570
571
589 bool replace=false,
590 IProxyDict* sg = 0);
591
592
606 bool replace,
607 const EventContext& ctx);
608
609
621 IProxyDict* sg=0);
622
623
631 const EventContext& ctx);
632
633
645 IProxyDict* sg=0);
646
647
655 const EventContext& ctx);
656
657
659
660
661 // Inherited from base class:
662 // bool isDefaultIndex() const
663 // Test the index validity.
664 // bool hasCachedElement() const
665 // Test to see if this link has a cached element pointer.
666 // bool isDefault() const
667 // Test to see if this link is in the default state.
668 // index_type index() const
669 // Return the index of the link.
670 // ID_type dataID() const
671 // Return the SG key that we reference, as a string.
672 // sgkey_t key() const
673 // Return the SG key that we reference, as a hash.
674 // IProxyDict* source() const
675 // Return the data source for the reference.
676 // void reset()
677 // Reset the link to a null state.
678 // bool toTransient (IProxyDict*)
679 // Finish initialization after link has been read.
680 // bool doPersistent()
681 // Prepare this link for writing.
682 // bool thin()
683 // bool thin(const SG::ThinningCache* thinningCache)
684 // Adjust for thinning.
685
686
687private:
694 const void* storable() const;
695
696
704};
705
706
712template <typename STORABLE>
714 const ElementLink<STORABLE>& rhs);
715
716
722template <typename STORABLE>
724 const ElementLink<STORABLE>& rhs);
725
726
732template <typename STORABLE>
734 const ElementLink<STORABLE>& rhs);
735
736
742template <typename STORABLE>
744 const ElementLink<STORABLE>& rhs);
745
746
747namespace SG_detail {
748
749
762bool checkForRemap (IProxyDict* sg,
763 SG::sgkey_t sgkey_in,
764 size_t index_in,
765 SG::sgkey_t& sgkey_out,
766 size_t& index_out);
767
768
780template <class T>
781inline
783 SG::sgkey_t sgkey_in,
784 const T& /*dum_in*/,
785 SG::sgkey_t& sgkey_out,
786 T& /*dum_out*/);
787
788
789} // namespace SG_detail
790
791
792namespace SG {
793
794
798template <class STORABLE>
799class ToTransient<ElementLink<STORABLE> >
800{
801public:
803 IProxyDict* sg = nullptr);
805 const EventContext& ctx);
806};
807
808
813template <class STORABLE, class ALLOC>
814class ToTransient<std::vector<ElementLink<STORABLE>, ALLOC> >
815{
816public:
817 static void toTransient (std::vector<ElementLink<STORABLE>, ALLOC>& elv,
818 IProxyDict* sg = nullptr);
819 static void toTransient (std::vector<ElementLink<STORABLE>, ALLOC>& elv,
820 const EventContext& ctx);
821};
822
823
824
829template <class STORABLE, class ALLOC1, class ALLOC2>
830class ToTransient<std::vector<std::vector<ElementLink<STORABLE>, ALLOC1>, ALLOC2> >
831{
832public:
833 static void toTransient (std::vector<std::vector<ElementLink<STORABLE>, ALLOC1>, ALLOC2>& elvv,
834 IProxyDict* sg = nullptr);
835 static void toTransient (std::vector<std::vector<ElementLink<STORABLE>, ALLOC1>, ALLOC2>& elvv,
836 const EventContext& ctx);
837};
838
839
840
841} // namespace SG
842
843
844namespace std {
845
846
847// C++20 compatible formatter.
848template <class T>
849struct formatter<ElementLink<T> >
850 : public formatter<string_view>
851{
852 template <class FmtContext>
853 FmtContext::iterator format(const ElementLink<T>& k, FmtContext& ctx) const
854 {
855 if (k.isDefault()) {
856 return formatter<string_view>::format ("(nullLink)", ctx);
857 }
858 return format_to (ctx.out(), "@{}[{}]", k.dataID(), k.index());
859 }
860};
861
862
863} // namespace std
864
865
866#include "AthLinks/ElementLink.icc"
867
868
869#endif // not ATHLINKS_ELEMENTLINK_H
Determine dependent types for ElementLink classes.
uint32_t CLID
The Class ID type.
unsigned int index_type
Define a hook for running code after an object has been read.
doing TRTHTH Hypo selection
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
ElementLinkTraits class to specialize.
Define a hook for running code after an object has been read.
Definition ToTransient.h:40
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312
bool checkForRemap(IProxyDict *sg, SG::sgkey_t sgkey_in, size_t index_in, SG::sgkey_t &sgkey_out, size_t &index_out)
See if an EL is being remapped.
Forward declaration.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
Definition index.py:1
STL namespace.
Some out-of-line helpers for ExtendedEventContext.