KiCad PCB EDA Suite
COBJECT2D_STATS Class Reference

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

#include <cobject2d.h>

Public Member Functions

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

Static Public Member Functions

static COBJECT2D_STATSInstance ()
 

Private Member Functions

 COBJECT2D_STATS ()
 
 COBJECT2D_STATS (const COBJECT2D_STATS &old)
 
const COBJECT2D_STATSoperator= (const COBJECT2D_STATS &old)
 
 ~COBJECT2D_STATS ()
 

Private Attributes

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

Static Private Attributes

static COBJECT2D_STATSs_instance = 0
 

Detailed Description

Implements a class for object statistics using Singleton pattern.

Definition at line 132 of file cobject2d.h.

Constructor & Destructor Documentation

◆ COBJECT2D_STATS() [1/2]

COBJECT2D_STATS::COBJECT2D_STATS ( )
inlineprivate

Definition at line 161 of file cobject2d.h.

161 { ResetStats(); }
void ResetStats()
Definition: cobject2d.h:135

References ResetStats().

Referenced by Instance().

◆ COBJECT2D_STATS() [2/2]

COBJECT2D_STATS::COBJECT2D_STATS ( const COBJECT2D_STATS old)
private

◆ ~COBJECT2D_STATS()

COBJECT2D_STATS::~COBJECT2D_STATS ( )
inlineprivate

Definition at line 164 of file cobject2d.h.

164 {}

Member Function Documentation

◆ AddOne()

void COBJECT2D_STATS::AddOne ( OBJECT2D_TYPE  aObjType)
inline

Definition at line 145 of file cobject2d.h.

146  {
147  m_counter[static_cast<int>( aObjType )]++;
148  }
unsigned int m_counter[static_cast< int >(OBJECT2D_TYPE::MAX)]
Definition: cobject2d.h:167

References m_counter.

Referenced by COBJECT2D::COBJECT2D().

◆ GetCountOf()

unsigned int COBJECT2D_STATS::GetCountOf ( OBJECT2D_TYPE  aObjType) const
inline

Definition at line 140 of file cobject2d.h.

141  {
142  return m_counter[static_cast<int>( aObjType )];
143  }
unsigned int m_counter[static_cast< int >(OBJECT2D_TYPE::MAX)]
Definition: cobject2d.h:167

References m_counter.

◆ Instance()

static COBJECT2D_STATS& COBJECT2D_STATS::Instance ( )
inlinestatic

Definition at line 152 of file cobject2d.h.

153  {
154  if( !s_instance )
156 
157  return *s_instance;
158  }
static COBJECT2D_STATS * s_instance
Definition: cobject2d.h:169

References COBJECT2D_STATS(), and s_instance.

Referenced by COBJECT2D::COBJECT2D(), C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

◆ operator=()

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

◆ PrintStats()

void COBJECT2D_STATS::PrintStats ( )

Definition at line 65 of file cobject2d.cpp.

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

References m_counter, and objectTypeNames.

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

◆ ResetStats()

void COBJECT2D_STATS::ResetStats ( )
inline

Definition at line 135 of file cobject2d.h.

136  {
137  memset( m_counter, 0, sizeof( unsigned int ) * static_cast<int>( OBJECT2D_TYPE::MAX ) );
138  }
unsigned int m_counter[static_cast< int >(OBJECT2D_TYPE::MAX)]
Definition: cobject2d.h:167

References m_counter, and MAX.

Referenced by COBJECT2D_STATS(), C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

Member Data Documentation

◆ m_counter

unsigned int COBJECT2D_STATS::m_counter[static_cast< int >(OBJECT2D_TYPE::MAX)]
private

Definition at line 167 of file cobject2d.h.

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

◆ s_instance

COBJECT2D_STATS * COBJECT2D_STATS::s_instance = 0
staticprivate

Definition at line 169 of file cobject2d.h.

Referenced by Instance().


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