Nektar++
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Nektar::CountedObject< DerivedType > Class Template Reference

#include <CountedObject.h>

Public Member Functions

 CountedObject ()
 
 CountedObject (unsigned int v)
 
 CountedObject (unsigned int a1, unsigned int a2)
 
 CountedObject (unsigned int a1, unsigned int a2, unsigned int a3)
 
 CountedObject (const CountedObject< DerivedType > &rhs)
 
virtual ~CountedObject ()
 
CountedObject< DerivedType > & operator= (const CountedObject< DerivedType > &rhs)
 
bool operator== (const CountedObject< DerivedType > &rhs) const
 
bool operator!= (const CountedObject< DerivedType > &rhs) const
 
CountedObject< DerivedType > * clone () const
 
unsigned int GetValue () const
 
 operator unsigned int () const
 

Static Public Member Functions

static void ClearCounters ()
 
static void Check (unsigned int expectedDefaultConstructed, unsigned int expectedConstructedFromInt, unsigned int expectedDestroyed, unsigned int expectedCopied, unsigned int expectedCloned, unsigned int expectedAssigned)
 

Public Attributes

unsigned int value
 

Static Public Attributes

static unsigned int numberDefaultConstructed = 0
 
static unsigned int numberConstructedFromInt = 0
 
static unsigned int numberDestroyed = 0
 
static unsigned int numberCopied = 0
 
static unsigned int numberAssigned = 0
 
static unsigned int numberCloned = 0
 
static unsigned int numberOf1ParameterConstructions = 0
 
static unsigned int numberOf2ParameterConstructions = 0
 
static unsigned int numberOf3ParameterConstructions = 0
 
static unsigned int numberOfExpressionConstructions = 0
 
static unsigned int numberOfExpressionAssignments = 0
 

Detailed Description

template<typename DerivedType>
class Nektar::CountedObject< DerivedType >

Definition at line 44 of file CountedObject.h.

Constructor & Destructor Documentation

◆ CountedObject() [1/5]

template<typename DerivedType >
Nektar::CountedObject< DerivedType >::CountedObject ( )
inline

Definition at line 47 of file CountedObject.h.

47 : value(0)
48 {
50 }
static unsigned int numberDefaultConstructed

References Nektar::CountedObject< DerivedType >::numberDefaultConstructed.

◆ CountedObject() [2/5]

template<typename DerivedType >
Nektar::CountedObject< DerivedType >::CountedObject ( unsigned int  v)
inlineexplicit

◆ CountedObject() [3/5]

template<typename DerivedType >
Nektar::CountedObject< DerivedType >::CountedObject ( unsigned int  a1,
unsigned int  a2 
)
inline

Definition at line 58 of file CountedObject.h.

58 : value(a1 + a2)
59 {
61 }
static unsigned int numberOf2ParameterConstructions

References Nektar::CountedObject< DerivedType >::numberOf2ParameterConstructions.

◆ CountedObject() [4/5]

template<typename DerivedType >
Nektar::CountedObject< DerivedType >::CountedObject ( unsigned int  a1,
unsigned int  a2,
unsigned int  a3 
)
inline

Definition at line 63 of file CountedObject.h.

64 : value(a1 + a2 + a3)
65 {
67 }
static unsigned int numberOf3ParameterConstructions

References Nektar::CountedObject< DerivedType >::numberOf3ParameterConstructions.

◆ CountedObject() [5/5]

template<typename DerivedType >
Nektar::CountedObject< DerivedType >::CountedObject ( const CountedObject< DerivedType > &  rhs)
inline

Definition at line 69 of file CountedObject.h.

69 : value(rhs.value)
70 {
72 }
static unsigned int numberCopied

References Nektar::CountedObject< DerivedType >::numberCopied.

◆ ~CountedObject()

template<typename DerivedType >
virtual Nektar::CountedObject< DerivedType >::~CountedObject ( )
inlinevirtual

Definition at line 74 of file CountedObject.h.

75 {
77 }
static unsigned int numberDestroyed

References Nektar::CountedObject< DerivedType >::numberDestroyed.

Member Function Documentation

◆ Check()

template<typename DerivedType >
static void Nektar::CountedObject< DerivedType >::Check ( unsigned int  expectedDefaultConstructed,
unsigned int  expectedConstructedFromInt,
unsigned int  expectedDestroyed,
unsigned int  expectedCopied,
unsigned int  expectedCloned,
unsigned int  expectedAssigned 
)
inlinestatic

Definition at line 117 of file CountedObject.h.

122 {
123 BOOST_CHECK_EQUAL(numberDefaultConstructed, expectedDefaultConstructed);
124 BOOST_CHECK_EQUAL(numberConstructedFromInt, expectedConstructedFromInt);
125 BOOST_CHECK_EQUAL(numberDestroyed, expectedDestroyed);
126 BOOST_CHECK_EQUAL(numberCopied, expectedCopied);
127 BOOST_CHECK_EQUAL(numberAssigned, expectedAssigned);
128 BOOST_CHECK_EQUAL(numberCloned, expectedCloned);
129 }
static unsigned int numberAssigned
static unsigned int numberCloned

References Nektar::CountedObject< DerivedType >::numberAssigned, Nektar::CountedObject< DerivedType >::numberCloned, Nektar::CountedObject< DerivedType >::numberConstructedFromInt, Nektar::CountedObject< DerivedType >::numberCopied, Nektar::CountedObject< DerivedType >::numberDefaultConstructed, and Nektar::CountedObject< DerivedType >::numberDestroyed.

Referenced by Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE().

◆ ClearCounters()

template<typename DerivedType >
static void Nektar::CountedObject< DerivedType >::ClearCounters ( )
inlinestatic

Definition at line 102 of file CountedObject.h.

References Nektar::CountedObject< DerivedType >::numberAssigned, Nektar::CountedObject< DerivedType >::numberCloned, Nektar::CountedObject< DerivedType >::numberConstructedFromInt, Nektar::CountedObject< DerivedType >::numberCopied, Nektar::CountedObject< DerivedType >::numberDefaultConstructed, Nektar::CountedObject< DerivedType >::numberDestroyed, Nektar::CountedObject< DerivedType >::numberOf1ParameterConstructions, Nektar::CountedObject< DerivedType >::numberOf2ParameterConstructions, Nektar::CountedObject< DerivedType >::numberOf3ParameterConstructions, Nektar::CountedObject< DerivedType >::numberOfExpressionAssignments, and Nektar::CountedObject< DerivedType >::numberOfExpressionConstructions.

Referenced by Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE(), and Nektar::MemManagerUnitTests::BOOST_AUTO_TEST_CASE().

◆ clone()

template<typename DerivedType >
CountedObject< DerivedType > * Nektar::CountedObject< DerivedType >::clone ( ) const
inline

Definition at line 96 of file CountedObject.h.

97 {
99 return new CountedObject<DerivedType>(*this);
100 }

References Nektar::CountedObject< DerivedType >::numberCloned.

◆ GetValue()

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::GetValue ( ) const
inline

Definition at line 131 of file CountedObject.h.

132 {
133 return value;
134 }

References Nektar::CountedObject< DerivedType >::value.

Referenced by Nektar::operator<<().

◆ operator unsigned int()

template<typename DerivedType >
Nektar::CountedObject< DerivedType >::operator unsigned int ( ) const
inline

Definition at line 135 of file CountedObject.h.

136 {
137 return value;
138 }

References Nektar::CountedObject< DerivedType >::value.

◆ operator!=()

template<typename DerivedType >
bool Nektar::CountedObject< DerivedType >::operator!= ( const CountedObject< DerivedType > &  rhs) const
inline

Definition at line 91 of file CountedObject.h.

92 {
93 return !(*this == rhs);
94 }

◆ operator=()

template<typename DerivedType >
CountedObject< DerivedType > & Nektar::CountedObject< DerivedType >::operator= ( const CountedObject< DerivedType > &  rhs)
inline

Definition at line 79 of file CountedObject.h.

80 {
82 value = rhs.value;
83 return *this;
84 }

References Nektar::CountedObject< DerivedType >::numberAssigned, and Nektar::CountedObject< DerivedType >::value.

◆ operator==()

template<typename DerivedType >
bool Nektar::CountedObject< DerivedType >::operator== ( const CountedObject< DerivedType > &  rhs) const
inline

Definition at line 86 of file CountedObject.h.

87 {
88 return value == rhs.value;
89 }

References Nektar::CountedObject< DerivedType >::value.

Member Data Documentation

◆ numberAssigned

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberAssigned = 0
static

◆ numberCloned

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberCloned = 0
static

◆ numberConstructedFromInt

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberConstructedFromInt = 0
static

◆ numberCopied

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberCopied = 0
static

◆ numberDefaultConstructed

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberDefaultConstructed = 0
static

◆ numberDestroyed

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberDestroyed = 0
static

◆ numberOf1ParameterConstructions

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberOf1ParameterConstructions = 0
static

◆ numberOf2ParameterConstructions

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberOf2ParameterConstructions = 0
static

◆ numberOf3ParameterConstructions

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberOf3ParameterConstructions = 0
static

◆ numberOfExpressionAssignments

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberOfExpressionAssignments = 0
static

◆ numberOfExpressionConstructions

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::numberOfExpressionConstructions = 0
static

◆ value

template<typename DerivedType >
unsigned int Nektar::CountedObject< DerivedType >::value