KiCad PCB EDA Suite
COBJECT3D_STATS Class Reference

Implements a class for object statistics using Singleton pattern. More...

#include <cobject.h>

Public Member Functions

void ResetStats ()
 
unsigned int GetCountOf (OBJECT3D_TYPE aObjType) const
 
void AddOne (OBJECT3D_TYPE aObjType)
 
void PrintStats ()
 

Static Public Member Functions

static COBJECT3D_STATSInstance ()
 

Private Member Functions

 COBJECT3D_STATS ()
 
 COBJECT3D_STATS (const COBJECT3D_STATS &old)
 
const COBJECT3D_STATSoperator= (const COBJECT3D_STATS &old)
 
 ~COBJECT3D_STATS ()
 

Private Attributes

unsigned int m_counter [static_cast< int >(OBJECT3D_TYPE::MAX)]
 

Static Private Attributes

static COBJECT3D_STATSs_instance = 0
 

Detailed Description

Implements a class for object statistics using Singleton pattern.

Definition at line 113 of file cobject.h.

Constructor & Destructor Documentation

◆ COBJECT3D_STATS() [1/2]

COBJECT3D_STATS::COBJECT3D_STATS ( )
inlineprivate

Definition at line 142 of file cobject.h.

142 { ResetStats(); }
void ResetStats()
Definition: cobject.h:116

References ResetStats().

Referenced by Instance().

◆ COBJECT3D_STATS() [2/2]

COBJECT3D_STATS::COBJECT3D_STATS ( const COBJECT3D_STATS old)
private

◆ ~COBJECT3D_STATS()

COBJECT3D_STATS::~COBJECT3D_STATS ( )
inlineprivate

Definition at line 145 of file cobject.h.

145 {}

Member Function Documentation

◆ AddOne()

void COBJECT3D_STATS::AddOne ( OBJECT3D_TYPE  aObjType)
inline

Definition at line 126 of file cobject.h.

127  {
128  m_counter[static_cast<int>( aObjType )]++;
129  }
unsigned int m_counter[static_cast< int >(OBJECT3D_TYPE::MAX)]
Definition: cobject.h:148

References m_counter.

Referenced by COBJECT::COBJECT().

◆ GetCountOf()

unsigned int COBJECT3D_STATS::GetCountOf ( OBJECT3D_TYPE  aObjType) const
inline

Definition at line 121 of file cobject.h.

122  {
123  return m_counter[static_cast<int>( aObjType )];
124  }
unsigned int m_counter[static_cast< int >(OBJECT3D_TYPE::MAX)]
Definition: cobject.h:148

References m_counter.

◆ Instance()

static COBJECT3D_STATS& COBJECT3D_STATS::Instance ( )
inlinestatic

Definition at line 133 of file cobject.h.

134  {
135  if( !s_instance )
137 
138  return *s_instance;
139  }
static COBJECT3D_STATS * s_instance
Definition: cobject.h:150

References COBJECT3D_STATS(), and s_instance.

Referenced by COBJECT::COBJECT(), and C3D_RENDER_RAYTRACING::reload().

◆ operator=()

const COBJECT3D_STATS& COBJECT3D_STATS::operator= ( const COBJECT3D_STATS old)
private

◆ PrintStats()

void COBJECT3D_STATS::PrintStats ( )

Definition at line 64 of file cobject.cpp.

65 {
66  printf( "OBJ3D Statistics:\n" );
67 
68  for( auto& objectType : objectTypeNames )
69  {
70  printf( " %20s %u\n", objectType.second,
71  m_counter[static_cast<int>( objectType.first )] );
72  }
73 }
unsigned int m_counter[static_cast< int >(OBJECT3D_TYPE::MAX)]
Definition: cobject.h:148
const std::map< OBJECT3D_TYPE, const char * > objectTypeNames
Definition: cobject.cpp:53

References m_counter, and objectTypeNames.

Referenced by C3D_RENDER_RAYTRACING::reload().

◆ ResetStats()

void COBJECT3D_STATS::ResetStats ( )
inline

Definition at line 116 of file cobject.h.

117  {
118  memset( m_counter, 0, sizeof( unsigned int ) * static_cast<int>( OBJECT3D_TYPE::MAX ) );
119  }
unsigned int m_counter[static_cast< int >(OBJECT3D_TYPE::MAX)]
Definition: cobject.h:148

References m_counter, and MAX.

Referenced by COBJECT3D_STATS(), and C3D_RENDER_RAYTRACING::reload().

Member Data Documentation

◆ m_counter

unsigned int COBJECT3D_STATS::m_counter[static_cast< int >(OBJECT3D_TYPE::MAX)]
private

Definition at line 148 of file cobject.h.

Referenced by AddOne(), GetCountOf(), PrintStats(), and ResetStats().

◆ s_instance

COBJECT3D_STATS * COBJECT3D_STATS::s_instance = 0
staticprivate

Definition at line 150 of file cobject.h.

Referenced by Instance().


The documentation for this class was generated from the following files: