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/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
13
14
15#ifndef ATHLINKS_ELEMENTLINK_H
16#define ATHLINKS_ELEMENTLINK_H
17
18
20#include "AthLinks/DataLink.h"
21#include <utility>
22
23
24class IProxyDict;
25class EventContext;
26
27
120template <class STORABLE>
122 : public SG::ElementLinkTraits<STORABLE>::Base
123{
124private:
127
129 typedef typename Traits::Base Base;
130
132 typedef typename Base::castfn_t castfn_t;
133
134
135public:
138
140 typedef typename IndexingPolicy::index_type index_type;
141
143 typedef typename Base::sgkey_t sgkey_t;
144
146 typedef typename Base::ID_type ID_type;
147
149 typedef STORABLE value_type;
150 typedef STORABLE* pointer;
151 typedef const STORABLE* const_pointer;
152 typedef const STORABLE& BaseConstReference;
153 typedef const STORABLE* BaseConstPointer;
154
155
157 typedef typename IndexingPolicy::ElementType ElementType;
158 typedef typename IndexingPolicy::ElementConstReference ElementConstReference;
159 typedef typename IndexingPolicy::ElementConstPointer ElementConstPointer;
160
161
165 static const CLID& classID();
166
167
168 //========================================================================
171
172
177
178
188 IProxyDict* sg = 0);
189
190
198 const EventContext& ctx);
199
200
210
211
218 ElementLink(sgkey_t key, index_type elemID, const EventContext& ctx);
219
220
233 index_type elemID,
234 ElementType pEl,
235 IProxyDict* sg = 0);
236
237
248 index_type elemID,
249 ElementType pEl,
250 const EventContext& ctx);
251
252
265 index_type elemID,
266 ElementType pEl,
267 IProxyDict* sg = 0);
268
269
280 index_type elemID,
281 ElementType pEl,
282 const EventContext& ctx);
283
284
294 index_type elemID,
295 IProxyDict* sg = 0);
296
297
305 index_type elemID,
306 const EventContext& ctx);
307
308
325 ElementLink (const ElementType& element,
327 IProxyDict* sg = 0);
328
329
344 ElementLink (const ElementType& element,
346 const EventContext& ctx);
347
348
357 ElementLink (const ElementLink& other, index_type elemID);
358
359
366
367
368 // Use default copy ctor.
369
370
374 template <class U>
376
377
378 // Default copy and assignment.
379 ElementLink (const ElementLink&) = default;
381
382
383 //@)
384 //========================================================================
387
388
395
396
403
404
409
410
415
416
421
422
427
428
436
437
444
445
450
451
455 operator ElementConstPointer () const;
456
457
464 bool isValid() const;
465
466
470 bool operator!() const;
471
472
477
478
479
480 //@)
481 //========================================================================
484
485
501 IProxyDict* sg = 0);
502
503
515 const EventContext& ctx);
516
517
535 ElementType element,
536 IProxyDict* sg = 0);
537
538
552 ElementType element,
553 const EventContext& ctx);
554
555
567 bool setElement(ElementType element);
568
569
587 bool replace=false,
588 IProxyDict* sg = 0);
589
590
604 bool replace,
605 const EventContext& ctx);
606
607
619 IProxyDict* sg=0);
620
621
629 const EventContext& ctx);
630
631
643 IProxyDict* sg=0);
644
645
653 const EventContext& ctx);
654
655
657
658
659 // Inherited from base class:
660 // bool isDefaultIndex() const
661 // Test the index validity.
662 // bool hasCachedElement() const
663 // Test to see if this link has a cached element pointer.
664 // bool isDefault() const
665 // Test to see if this link is in the default state.
666 // index_type index() const
667 // Return the index of the link.
668 // ID_type dataID() const
669 // Return the SG key that we reference, as a string.
670 // sgkey_t key() const
671 // Return the SG key that we reference, as a hash.
672 // IProxyDict* source() const
673 // Return the data source for the reference.
674 // void reset()
675 // Reset the link to a null state.
676 // bool toTransient (IProxyDict*)
677 // Finish initialization after link has been read.
678 // bool doPersistent()
679 // Prepare this link for writing.
680 // bool thin()
681 // bool thin(const SG::ThinningCache* thinningCache)
682 // Adjust for thinning.
683
684
685private:
692 const void* storable() const;
693
694
702};
703
704
710template <typename STORABLE>
712 const ElementLink<STORABLE>& rhs);
713
714
720template <typename STORABLE>
722 const ElementLink<STORABLE>& rhs);
723
724
730template <typename STORABLE>
732 const ElementLink<STORABLE>& rhs);
733
734
740template <typename STORABLE>
742 const ElementLink<STORABLE>& rhs);
743
744
745namespace SG_detail {
746
747
760bool checkForRemap (IProxyDict* sg,
761 SG::sgkey_t sgkey_in,
762 size_t index_in,
763 SG::sgkey_t& sgkey_out,
764 size_t& index_out);
765
766
778template <class T>
779inline
781 SG::sgkey_t sgkey_in,
782 const T& /*dum_in*/,
783 SG::sgkey_t& sgkey_out,
784 T& /*dum_out*/);
785
786
787} // namespace SG_detail
788
789
790namespace std {
791
792
832template <typename CONT, typename T2>
833struct pair<ElementLink<CONT>, T2>
834{
835 // Standard pair types.
837 typedef T2 second_type;
838
839 // Standard pair members.
842
843 // Standard pair constructors.
844 pair() : first(), second() {}
845 pair (const first_type& x, const second_type& y) : first (x), second (y) {}
846 template <class U, class V>
847 pair (const pair<U, V>& p) : first (p.first), second (p.second) {}
848
849 // Helper type.
852
853 // Extra constructor to allow avoiding a temporary for the
854 // @c ElementLink initialization.
855 pair (const CONT& child_container,
857 const T2& y)
858 : first (child_container, index), second (y)
859 {}
860
861 // Extra constructor to allow avoiding a temporary for the
862 // @c ElementLink initialization.
863 pair (const CONT& child_container,
865 IProxyDict* sg,
866 const T2& y)
867 : first (child_container, index, sg), second (y)
868 {}
869
870 void swap (pair& p)
871 {
872 std::swap (first, p.first);
873 std::swap (second, p.second);
874 }
875};
876
877
878} // namespace std
879
880
881#include "AthLinks/ElementLink.icc"
882
883
884#endif // not ATHLINKS_ELEMENTLINK_H
Determine dependent types for ElementLink classes.
uint32_t CLID
The Class ID type.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define y
#define x
ElementLinkTraits class to specialize.
ElementLinkTraits1< STORABLE >::IndexingPolicy IndexingPolicy
ElementLinkTraits1< STORABLE >::Base Base
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310
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.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
Definition index.py:1
STL namespace.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)