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
620 const EventContext& ctx);
621
622
634 IProxyDict* sg=0);
635
636
644 const EventContext& ctx);
645
646
658 IProxyDict* sg=0);
659
660
668 const EventContext& ctx);
669
670
672
673
674 // Inherited from base class:
675 // bool isDefaultIndex() const
676 // Test the index validity.
677 // bool hasCachedElement() const
678 // Test to see if this link has a cached element pointer.
679 // bool isDefault() const
680 // Test to see if this link is in the default state.
681 // index_type index() const
682 // Return the index of the link.
683 // ID_type dataID() const
684 // Return the SG key that we reference, as a string.
685 // sgkey_t key() const
686 // Return the SG key that we reference, as a hash.
687 // IProxyDict* source() const
688 // Return the data source for the reference.
689 // void reset()
690 // Reset the link to a null state.
691 // bool toTransient (IProxyDict*)
692 // Finish initialization after link has been read.
693 // bool doPersistent()
694 // Prepare this link for writing.
695 // bool thin()
696 // bool thin(const SG::ThinningCache* thinningCache)
697 // Adjust for thinning.
698
699
700private:
707 const void* storable() const;
708
709
717};
718
719
725template <typename STORABLE>
727 const ElementLink<STORABLE>& rhs);
728
729
735template <typename STORABLE>
737 const ElementLink<STORABLE>& rhs);
738
739
745template <typename STORABLE>
747 const ElementLink<STORABLE>& rhs);
748
749
755template <typename STORABLE>
757 const ElementLink<STORABLE>& rhs);
758
759
760namespace SG_detail {
761
762
775bool checkForRemap (IProxyDict* sg,
776 SG::sgkey_t sgkey_in,
777 size_t index_in,
778 SG::sgkey_t& sgkey_out,
779 size_t& index_out);
780
781
793template <class T>
794inline
796 SG::sgkey_t sgkey_in,
797 const T& /*dum_in*/,
798 SG::sgkey_t& sgkey_out,
799 T& /*dum_out*/);
800
801
802} // namespace SG_detail
803
804
805namespace SG {
806
807
811template <class STORABLE>
812class ToTransient<ElementLink<STORABLE> >
813{
814public:
816 IProxyDict* sg = nullptr);
818 const EventContext& ctx);
819};
820
821
826template <class STORABLE, class ALLOC>
827class ToTransient<std::vector<ElementLink<STORABLE>, ALLOC> >
828{
829public:
830 static void toTransient (std::vector<ElementLink<STORABLE>, ALLOC>& elv,
831 IProxyDict* sg = nullptr);
832 static void toTransient (std::vector<ElementLink<STORABLE>, ALLOC>& elv,
833 const EventContext& ctx);
834};
835
836
837
842template <class STORABLE, class ALLOC1, class ALLOC2>
843class ToTransient<std::vector<std::vector<ElementLink<STORABLE>, ALLOC1>, ALLOC2> >
844{
845public:
846 static void toTransient (std::vector<std::vector<ElementLink<STORABLE>, ALLOC1>, ALLOC2>& elvv,
847 IProxyDict* sg = nullptr);
848 static void toTransient (std::vector<std::vector<ElementLink<STORABLE>, ALLOC1>, ALLOC2>& elvv,
849 const EventContext& ctx);
850};
851
852
853
854} // namespace SG
855
856
857namespace std {
858
859
860// C++20 compatible formatter.
861template <class T>
862struct formatter<ElementLink<T> >
863 : public formatter<string_view>
864{
865 template <class FmtContext>
866 FmtContext::iterator format(const ElementLink<T>& k, FmtContext& ctx) const
867 {
868 if (k.isDefault()) {
869 return formatter<string_view>::format ("(nullLink)", ctx);
870 }
871 return format_to (ctx.out(), "@{}[{}]", k.dataID(), k.index());
872 }
873};
874
875
876} // namespace std
877
878
879#include "AthLinks/ElementLink.icc"
880
881
882#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.