ATLAS Offline Software
AthToolSupport/AsgTools/AsgTools/SlotSpecificObj.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration.
3  */
4 
12 #ifndef ASGTOOLS_SLOTSPECIFICOBJ_H
13 #define ASGTOOLS_SLOTSPECIFICOBJ_H
14 
15 #ifndef XAOD_STANDALONE
17 #else
18 
19 #include <array>
20 #include <string>
21 
22 class EventContext;
23 
24 namespace SG {
25 
35 template <class T>
36 class SlotSpecificObj
37 {
38 public:
39  SlotSpecificObj() = default;
40  SlotSpecificObj (size_t /*nslots*/) : SlotSpecificObj() {}
41 
43  T* get (const EventContext&) { return get(); }
44  T* get() { return &m_slots[0]; }
45  const T* get (const EventContext&) const { return get(); }
46  const T* get() const { return &m_slots[0]; }
48 
50  T& operator* () { return *get(); }
51  const T& operator* () const { return *get(); }
52  T* operator-> () { return get(); }
53  const T* operator-> () const { return get(); }
55 
57  typedef typename std::array<T,1>::iterator iterator;
58  typedef typename std::array<T,1>::const_iterator const_iterator;
59  typedef typename std::array<T,1>::value_type value_type;
60 
61  iterator begin() { return m_slots.begin(); }
62  const_iterator begin() const { return m_slots.begin(); }
63  iterator end() { return m_slots.end(); }
64  const_iterator end() const { return m_slots.end(); }
66 
67 private:
69  std::array<T,1> m_slots{};
70 };
71 
72 } // namespace SG
73 
74 #endif // XAOD_STANDALONE
75 #endif // ASGTOOLS_SLOTSPECIFICOBJ_H
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::SlotSpecificObj::m_slots
std::vector< T > m_slots
Set of per-slot objects.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:185
SG::SlotSpecificObj::end
iterator end()
End iterator.
SG::SlotSpecificObj::get
T * get()
Return pointer to the object for the current slot.
SG::SlotSpecificObj::operator->
T * operator->()
Dereference the pointer.
SG::SlotSpecificObj::begin
iterator begin()
Begin iterator.
SG::SlotSpecificObj::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:155
SG::SlotSpecificObj::value_type
std::vector< T >::value_type value_type
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:156
SG::SlotSpecificObj::iterator
std::vector< T >::iterator iterator
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:154
SlotSpecificObj.h
Maintain a set of objects, one per slot.
SG::SlotSpecificObj::SlotSpecificObj
SlotSpecificObj()
Constructor.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
SG::SlotSpecificObj::operator*
T & operator*()
Dereference the pointer.