ATLAS Offline Software
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-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
15 #ifndef ATHLINKS_ELEMENTLINK_H
16 #define ATHLINKS_ELEMENTLINK_H
17 
18 
20 #include "AthLinks/DataLink.h"
21 #include <utility>
22 
23 
24 class IProxyDict;
25 class EventContext;
26 
27 
120 template <class STORABLE>
122  : public SG::ElementLinkTraits<STORABLE>::Base
123 {
124 private:
127 
129  typedef typename Traits::Base Base;
130 
132  typedef typename Base::castfn_t castfn_t;
133 
134 
135 public:
138 
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 
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;
380  ElementLink& operator= (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 
685 private:
692  const void* storable() const;
693 
694 
702 };
703 
704 
710 template <typename STORABLE>
712  const ElementLink<STORABLE>& rhs);
713 
714 
720 template <typename STORABLE>
722  const ElementLink<STORABLE>& rhs);
723 
724 
730 template <typename STORABLE>
732  const ElementLink<STORABLE>& rhs);
733 
734 
740 template <typename STORABLE>
742  const ElementLink<STORABLE>& rhs);
743 
744 
745 namespace SG_detail {
746 
747 
760 inline
762  SG::sgkey_t sgkey_in,
763  size_t index_in,
764  SG::sgkey_t& sgkey_out,
765  size_t& index_out);
766 
767 
779 template <class T>
780 inline
782  SG::sgkey_t sgkey_in,
783  const T& /*dum_in*/,
784  SG::sgkey_t& sgkey_out,
785  T& /*dum_out*/);
786 
787 
788 } // namespace SG_detail
789 
790 
791 namespace std {
792 
793 
833 template <typename CONT, typename T2>
834 struct pair<ElementLink<CONT>, T2>
835 {
836  // Standard pair types.
838  typedef T2 second_type;
839 
840  // Standard pair members.
843 
844  // Standard pair constructors.
845  pair() : first(), second() {}
846  pair (const first_type& x, const second_type& y) : first (x), second (y) {}
847  template <class U, class V>
848  pair (const pair<U, V>& p) : first (p.first), second (p.second) {}
849 
850  // Helper type.
853 
854  // Extra constructor to allow avoiding a temporary for the
855  // @c ElementLink initialization.
856  pair (const CONT& child_container,
857  const external_index_type& index,
858  const T2& y)
859  : first (child_container, index), second (y)
860  {}
861 
862  // Extra constructor to allow avoiding a temporary for the
863  // @c ElementLink initialization.
864  pair (const CONT& child_container,
865  const external_index_type& index,
866  IProxyDict* sg,
867  const T2& y)
868  : first (child_container, index, sg), second (y)
869  {}
870 
871  void swap (pair& p)
872  {
873  std::swap (first, p.first);
874  std::swap (second, p.second);
875  }
876 };
877 
878 
879 } // namespace std
880 
881 
882 #include "AthLinks/ElementLink.icc"
883 
884 
885 #endif // not ATHLINKS_ELEMENTLINK_H
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
SG_detail::checkForRemap
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.
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SG_detail
Definition: AthLinks/ElementLink.h:745
index
Definition: index.py:1
ElementLinkTraits.h
Determine dependent types for ElementLink classes.
x
#define x
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::GenericElementLinkBase::ID_type
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
Definition: GenericElementLinkBase.h:98
SG::GenericElementLinkBase
Generic base class for ElementLinks.
Definition: AthLinks/DataLinkBase.h:26
SG::ElementLinkTraits::IndexingPolicy
ElementLinkTraits1< STORABLE >::IndexingPolicy IndexingPolicy
Definition: ElementLinkTraits.h:197
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::ElementLinkTraits
ElementLinkTraits class to specialize.
Definition: ElementLinkTraits.h:193
SG::GenericElementLinkBase::index_type
INDEXING_POLICY::index_type index_type
The index type presented to and returned from the link.
Definition: GenericElementLinkBase.h:89
SG::GenericElementLinkBase::sgkey_t
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
Definition: GenericElementLinkBase.h:95
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::GenericElementLinkBase::ElementConstPointer
INDEXING_POLICY::ElementConstPointer ElementConstPointer
Definition: GenericElementLinkBase.h:81
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
y
#define y
DeMoScan.first
bool first
Definition: DeMoScan.py:536
SG::GenerateIndexingPolicy
Definition: GenerateIndexingPolicy.h:30
SG::GenericElementLinkBase::ElementType
INDEXING_POLICY::ElementType ElementType
Generic pointer to an element.
Definition: GenericElementLinkBase.h:80
SG::GenericElementLinkBase::castfn_t
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
Definition: GenericElementLinkBase.h:101
index_type
unsigned int index_type
Definition: FPGATrackSimSGToRawHitsTool.h:37