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"
22 #include "GaudiKernel/EventContext.h"
23 #include <utility>
24 
25 
118 template <class STORABLE>
120  : public SG::ElementLinkTraits<STORABLE>::Base
121 {
122 private:
125 
127  typedef typename Traits::Base Base;
128 
130  typedef typename Base::castfn_t castfn_t;
131 
132 
133 public:
136 
139 
141  typedef typename Base::sgkey_t sgkey_t;
142 
144  typedef typename Base::ID_type ID_type;
145 
147  typedef STORABLE value_type;
148  typedef STORABLE* pointer;
149  typedef const STORABLE* const_pointer;
150  typedef const STORABLE& BaseConstReference;
151  typedef const STORABLE* BaseConstPointer;
152 
153 
155  typedef typename IndexingPolicy::ElementType ElementType;
156  typedef typename IndexingPolicy::ElementConstReference ElementConstReference;
157  typedef typename IndexingPolicy::ElementConstPointer ElementConstPointer;
158 
159 
163  static const CLID& classID();
164 
165 
166  //========================================================================
169 
170 
175 
176 
186  IProxyDict* sg = 0);
187 
188 
196  const EventContext& ctx);
197 
198 
208 
209 
216  ElementLink(sgkey_t key, index_type elemID, const EventContext& ctx);
217 
218 
231  index_type elemID,
232  ElementType pEl,
233  IProxyDict* sg = 0);
234 
235 
246  index_type elemID,
247  ElementType pEl,
248  const EventContext& ctx);
249 
250 
263  index_type elemID,
264  ElementType pEl,
265  IProxyDict* sg = 0);
266 
267 
278  index_type elemID,
279  ElementType pEl,
280  const EventContext& ctx);
281 
282 
292  index_type elemID,
293  IProxyDict* sg = 0);
294 
295 
303  index_type elemID,
304  const EventContext& ctx);
305 
306 
323  ElementLink (const ElementType& element,
325  IProxyDict* sg = 0);
326 
327 
342  ElementLink (const ElementType& element,
344  const EventContext& ctx);
345 
346 
356 
357 
364 
365 
366  // Use default copy ctor.
367 
368 
372  template <class U>
374 
375 
376  // Default copy and assignment.
377  ElementLink (const ElementLink&) = default;
378  ElementLink& operator= (const ElementLink&) = default;
379 
380 
381  //@)
382  //========================================================================
385 
386 
393 
394 
401 
402 
407 
408 
413 
414 
419 
420 
425 
426 
434 
435 
442 
443 
448 
449 
453  operator ElementConstPointer () const;
454 
455 
462  bool isValid() const;
463 
464 
468  bool operator!() const;
469 
470 
475 
476 
477 
478  //@)
479  //========================================================================
482 
483 
499  IProxyDict* sg = 0);
500 
501 
513  const EventContext& ctx);
514 
515 
533  ElementType element,
534  IProxyDict* sg = 0);
535 
536 
550  ElementType element,
551  const EventContext& ctx);
552 
553 
565  bool setElement(ElementType element);
566 
567 
585  bool replace=false,
586  IProxyDict* sg = 0);
587 
588 
602  bool replace,
603  const EventContext& ctx);
604 
605 
617  IProxyDict* sg=0);
618 
619 
627  const EventContext& ctx);
628 
629 
641  IProxyDict* sg=0);
642 
643 
651  const EventContext& ctx);
652 
653 
655 
656 
657  // Inherited from base class:
658  // bool isDefaultIndex() const
659  // Test the index validity.
660  // bool hasCachedElement() const
661  // Test to see if this link has a cached element pointer.
662  // bool isDefault() const
663  // Test to see if this link is in the default state.
664  // index_type index() const
665  // Return the index of the link.
666  // ID_type dataID() const
667  // Return the SG key that we reference, as a string.
668  // sgkey_t key() const
669  // Return the SG key that we reference, as a hash.
670  // IProxyDict* source() const
671  // Return the data source for the reference.
672  // void reset()
673  // Reset the link to a null state.
674  // bool toTransient (IProxyDict*)
675  // Finish initialization after link has been read.
676  // bool doPersistent()
677  // Prepare this link for writing.
678  // bool thin()
679  // bool thin(const SG::ThinningCache* thinningCache)
680  // Adjust for thinning.
681 
682 
683 private:
690  const void* storable() const;
691 
692 
700 };
701 
702 
708 template <typename STORABLE>
710  const ElementLink<STORABLE>& rhs);
711 
712 
718 template <typename STORABLE>
720  const ElementLink<STORABLE>& rhs);
721 
722 
728 template <typename STORABLE>
730  const ElementLink<STORABLE>& rhs);
731 
732 
738 template <typename STORABLE>
740  const ElementLink<STORABLE>& rhs);
741 
742 
743 namespace SG_detail {
744 
745 
758 inline
760  SG::sgkey_t sgkey_in,
761  size_t index_in,
762  SG::sgkey_t& sgkey_out,
763  size_t& index_out);
764 
765 
777 template <class T>
778 inline
780  SG::sgkey_t sgkey_in,
781  const T& /*dum_in*/,
782  SG::sgkey_t& sgkey_out,
783  T& /*dum_out*/);
784 
785 
786 } // namespace SG_detail
787 
788 
789 namespace std {
790 
791 
831 template <typename CONT, typename T2>
832 struct pair<ElementLink<CONT>, T2>
833 {
834  // Standard pair types.
836  typedef T2 second_type;
837 
838  // Standard pair members.
841 
842  // Standard pair constructors.
843  pair() : first(), second() {}
844  pair (const first_type& x, const second_type& y) : first (x), second (y) {}
845  template <class U, class V>
846  pair (const pair<U, V>& p) : first (p.first), second (p.second) {}
847 
848  // Helper type.
851 
852  // Extra constructor to allow avoiding a temporary for the
853  // @c ElementLink initialization.
854  pair (const CONT& child_container,
855  const external_index_type& index,
856  const T2& y)
857  : first (child_container, index), second (y)
858  {}
859 
860  // Extra constructor to allow avoiding a temporary for the
861  // @c ElementLink initialization.
862  pair (const CONT& child_container,
863  const external_index_type& index,
864  IProxyDict* sg,
865  const T2& y)
866  : first (child_container, index, sg), second (y)
867  {}
868 
869  void swap (pair& p)
870  {
871  std::swap (first, p.first);
872  std::swap (second, p.second);
873  }
874 };
875 
876 
877 } // namespace std
878 
879 
880 #include "AthLinks/ElementLink.icc"
881 
882 
883 #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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG_detail
Definition: AthLinks/ElementLink.h:743
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:51
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:24
SG::ElementLinkTraits::IndexingPolicy
ElementLinkTraits1< STORABLE >::IndexingPolicy IndexingPolicy
Definition: ElementLinkTraits.h:197
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
IProxyDict.h
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:534
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