ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
SG::IndexHolder< T > Class Template Reference

Store an ElementLink index for non-vector containers. More...

#include <IndexHolder.h>

Collaboration diagram for SG::IndexHolder< T >:

Public Member Functions

 IndexHolder ()
 Constructor. More...
 
 IndexHolder (const T &t)
 Copy constructor. More...
 
bool isValid () const
 Return valid flag. More...
 
void reset ()
 Reset the index to a null value. More...
 
 operator const T & () const
 Retrieve the index. More...
 

Private Attributes

m_index
 The stored index. More...
 
bool m_valid
 True if the index is valid. More...
 

Detailed Description

template<class T>
class SG::IndexHolder< T >

Store an ElementLink index for non-vector containers.

When we store an index to a vector container, we use -1 as an invalid index value. However, in the general case where we have a container with an index of arbitrary type, we don't have a distinguished value we can use to represent invalid. So for that case, we need to store an additional valid flag along with the index. Things are factored like this so that we can avoid storing the flag for the common case of indexing a vector.

Definition at line 35 of file IndexHolder.h.

Constructor & Destructor Documentation

◆ IndexHolder() [1/2]

template<class T >
SG::IndexHolder< T >::IndexHolder ( )
inline

Constructor.

Definition at line 39 of file IndexHolder.h.

39 : m_index(), m_valid(false) {}

◆ IndexHolder() [2/2]

template<class T >
SG::IndexHolder< T >::IndexHolder ( const T &  t)
inline

Copy constructor.

Definition at line 42 of file IndexHolder.h.

42 : m_index(t), m_valid(true) {}

Member Function Documentation

◆ isValid()

template<class T >
bool SG::IndexHolder< T >::isValid ( ) const
inline

Return valid flag.

Definition at line 45 of file IndexHolder.h.

45 { return m_valid; }

◆ operator const T &()

template<class T >
SG::IndexHolder< T >::operator const T & ( ) const
inline

Retrieve the index.

Definition at line 51 of file IndexHolder.h.

51 { return m_index; }

◆ reset()

template<class T >
void SG::IndexHolder< T >::reset ( )
inline

Reset the index to a null value.

Definition at line 48 of file IndexHolder.h.

48 { m_valid = false; m_index = T(); }

Member Data Documentation

◆ m_index

template<class T >
T SG::IndexHolder< T >::m_index
private

The stored index.

Definition at line 56 of file IndexHolder.h.

◆ m_valid

template<class T >
bool SG::IndexHolder< T >::m_valid
private

True if the index is valid.

Definition at line 59 of file IndexHolder.h.


The documentation for this class was generated from the following file:
SG::IndexHolder::m_index
T m_index
The stored index.
Definition: IndexHolder.h:56
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::IndexHolder::m_valid
bool m_valid
True if the index is valid.
Definition: IndexHolder.h:59
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35