ATLAS Offline Software
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
ObjRef Class Reference

Helper class to refer to objects in the container ObjContainer. More...

#include <ObjContainer.h>

Collaboration diagram for ObjRef:

Public Member Functions

 ObjRef ()=default
 
 ObjRef (unsigned short idx)
 
 ObjRef (const ObjRef &ref)=default
 
 ObjRef (ObjRef &&ref)
 
bool isValid () const
 Return true if this class refers to an object which used to exist in the container. More...
 
 operator bool () const
 See isValid. More...
 
ObjRefoperator= (const ObjRef &ref)=default
 
ObjRefoperator= (ObjRef &&ref)
 
bool operator== (const ObjRef &obj) const
 
bool operator!= (const ObjRef &obj) const
 

Private Member Functions

unsigned short idx () const
 

Static Private Member Functions

static constexpr unsigned short invalid ()
 

Private Attributes

unsigned short m_index = invalid()
 

Friends

template<class T_Obj_ >
class ObjContainer
 
template<class T_Obj_ >
class ObjPtr
 

Detailed Description

Helper class to refer to objects in the container ObjContainer.

Does not provide object lifetime guarantees. The latter is only guaranteed if an ObjPtr matching this reference is still instantiated.

Definition at line 61 of file ObjContainer.h.

Constructor & Destructor Documentation

◆ ObjRef() [1/4]

ObjRef::ObjRef ( )
default

◆ ObjRef() [2/4]

ObjRef::ObjRef ( unsigned short  idx)
inline

Definition at line 70 of file ObjContainer.h.

70 : m_index(idx) {}

◆ ObjRef() [3/4]

ObjRef::ObjRef ( const ObjRef ref)
default

◆ ObjRef() [4/4]

ObjRef::ObjRef ( ObjRef &&  ref)
inline

Definition at line 74 of file ObjContainer.h.

74 : m_index(ref.m_index) {ref.m_index=invalid(); }

Member Function Documentation

◆ idx()

unsigned short ObjRef::idx ( ) const
inlineprivate

Definition at line 104 of file ObjContainer.h.

104 { return m_index; };

◆ invalid()

static constexpr unsigned short ObjRef::invalid ( )
inlinestaticconstexprprivate

Definition at line 106 of file ObjContainer.h.

◆ isValid()

bool ObjRef::isValid ( ) const
inline

Return true if this class refers to an object which used to exist in the container.

If true there is still no guarantee that the object is still alive.

Definition at line 79 of file ObjContainer.h.

79 { return m_index != invalid(); }

◆ operator bool()

ObjRef::operator bool ( ) const
inline

See isValid.

Definition at line 83 of file ObjContainer.h.

83 { return isValid(); }

◆ operator!=()

bool ObjRef::operator!= ( const ObjRef obj) const
inline

Definition at line 99 of file ObjContainer.h.

99  {
100  return obj.idx() != idx();
101  }

◆ operator=() [1/2]

ObjRef& ObjRef::operator= ( const ObjRef ref)
default

◆ operator=() [2/2]

ObjRef& ObjRef::operator= ( ObjRef &&  ref)
inline

Definition at line 87 of file ObjContainer.h.

87  {
88  if (this != &ref) {
89  m_index=ref.m_index;
90  ref.m_index = invalid();
91  }
92  return *this;
93  }

◆ operator==()

bool ObjRef::operator== ( const ObjRef obj) const
inline

Definition at line 95 of file ObjContainer.h.

95  {
96  return obj.idx() == idx();
97  }

Friends And Related Function Documentation

◆ ObjContainer

template<class T_Obj_ >
friend class ObjContainer
friend

Definition at line 63 of file ObjContainer.h.

◆ ObjPtr

template<class T_Obj_ >
friend class ObjPtr
friend

Definition at line 65 of file ObjContainer.h.

Member Data Documentation

◆ m_index

unsigned short ObjRef::m_index = invalid()
private

Definition at line 107 of file ObjContainer.h.


The documentation for this class was generated from the following file:
max
#define max(a, b)
Definition: cfImp.cxx:41
ObjRef::m_index
unsigned short m_index
Definition: ObjContainer.h:107
ObjRef::idx
unsigned short idx() const
Definition: ObjContainer.h:104
ObjRef::isValid
bool isValid() const
Return true if this class refers to an object which used to exist in the container.
Definition: ObjContainer.h:79
ref
const boost::regex ref(r_ef)
python.PyAthena.obj
obj
Definition: PyAthena.py:132
ObjRef::invalid
static constexpr unsigned short invalid()
Definition: ObjContainer.h:106