ATLAS Offline Software
IndexHolder.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-2024 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef ATHLINKS_INDEXHOLDER_H
14 #define ATHLINKS_INDEXHOLDER_H
15 
16 
17 namespace SG {
18 
19 
31 template <class T>
33 {
34 public:
36  IndexHolder() : m_index(), m_valid(false) {}
37 
39  IndexHolder (const T& t) : m_index(t), m_valid(true) {}
40 
42  bool isValid() const { return m_valid; }
43 
45  void reset() { m_valid = false; m_index = T(); }
46 
48  // cppcheck-suppress returnByReference
49  operator const T&() const { return m_index; }
50 
51 
52 private:
55 
57  bool m_valid;
58 };
59 
60 
61 } // namespace SG
62 
63 
64 #endif // not ATHLINKS_INDEXHOLDER_H
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::IndexHolder::IndexHolder
IndexHolder(const T &t)
Copy constructor.
Definition: IndexHolder.h:39
SG::IndexHolder::m_index
T m_index
The stored index.
Definition: IndexHolder.h:54
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::IndexHolder::reset
void reset()
Reset the index to a null value.
Definition: IndexHolder.h:45
SG::IndexHolder::IndexHolder
IndexHolder()
Constructor.
Definition: IndexHolder.h:36
SG::IndexHolder::m_valid
bool m_valid
True if the index is valid.
Definition: IndexHolder.h:57
SG::IndexHolder
Store an ElementLink index for non-vector containers.
Definition: IndexHolder.h:33
SG::IndexHolder::isValid
bool isValid() const
Return valid flag.
Definition: IndexHolder.h:42