ATLAS Offline Software
Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Trk::ObjectCounter< T > Class Template Reference

Helper to enable counting number of instantiations in debug builds. More...

#include <TrkObjectCounter.h>

Collaboration diagram for Trk::ObjectCounter< T >:

Static Public Member Functions

static std::size_t numberOfInstantiations ()
 

Static Public Attributes

static std::atomic_size_t s_numberOfInstantiations = 0
 

Protected Member Functions

 ObjectCounter ()
 
 ObjectCounter (const ObjectCounter &)
 
 ~ObjectCounter ()
 
ObjectCounteroperator= (const ObjectCounter &)=default
 
 ObjectCounter (ObjectCounter &&)=default
 
ObjectCounteroperator= (ObjectCounter &&)=default
 

Detailed Description

template<typename T>
class Trk::ObjectCounter< T >

Helper to enable counting number of instantiations in debug builds.

Author
Christos Anastopoulos.

Definition at line 17 of file TrkObjectCounter.h.

Constructor & Destructor Documentation

◆ ObjectCounter() [1/3]

template<typename T >
Trk::ObjectCounter< T >::ObjectCounter ( )
inlineprotected

Definition at line 36 of file TrkObjectCounter.h.

37  {
38  s_numberOfInstantiations.fetch_add(1, std::memory_order_relaxed);
39  }

◆ ObjectCounter() [2/3]

template<typename T >
Trk::ObjectCounter< T >::ObjectCounter ( const ObjectCounter< T > &  )
inlineprotected

Definition at line 40 of file TrkObjectCounter.h.

41  {
42  s_numberOfInstantiations.fetch_add(1, std::memory_order_relaxed);
43  }

◆ ~ObjectCounter()

template<typename T >
Trk::ObjectCounter< T >::~ObjectCounter ( )
inlineprotected

Definition at line 44 of file TrkObjectCounter.h.

45  {
46  s_numberOfInstantiations.fetch_sub(1, std::memory_order_relaxed);
47  }

◆ ObjectCounter() [3/3]

template<typename T >
Trk::ObjectCounter< T >::ObjectCounter ( ObjectCounter< T > &&  )
protecteddefault

Member Function Documentation

◆ numberOfInstantiations()

template<typename T >
static std::size_t Trk::ObjectCounter< T >::numberOfInstantiations ( )
inlinestatic

Definition at line 25 of file TrkObjectCounter.h.

26  {
27 #ifndef NDEBUG
28  return s_numberOfInstantiations.load();
29 #endif
30  return 0;
31  }

◆ operator=() [1/2]

template<typename T >
ObjectCounter& Trk::ObjectCounter< T >::operator= ( const ObjectCounter< T > &  )
protecteddefault

◆ operator=() [2/2]

template<typename T >
ObjectCounter& Trk::ObjectCounter< T >::operator= ( ObjectCounter< T > &&  )
protecteddefault

Member Data Documentation

◆ s_numberOfInstantiations

template<typename T >
std::atomic_size_t Trk::ObjectCounter< T >::s_numberOfInstantiations = 0
inlinestatic

Definition at line 22 of file TrkObjectCounter.h.


The documentation for this class was generated from the following file:
Trk::ObjectCounter::s_numberOfInstantiations
static std::atomic_size_t s_numberOfInstantiations
Definition: TrkObjectCounter.h:22