KiCad PCB EDA Suite
ENUM_MAP< T > Class Template Reference

#include <property.h>

Public Member Functions

ENUM_MAPMap (T aValue, const wxString &aName)
 
ENUM_MAPUndefined (T aValue)
 
const wxString & ToString (T value) const
 
const T ToEnum (const wxString value)
 
wxPGChoices & Choices ()
 

Static Public Member Functions

static ENUM_MAP< T > & Instance ()
 

Private Member Functions

 ENUM_MAP ()
 

Private Attributes

wxPGChoices m_choices
 
std::unordered_map< wxString, T > m_reverseMap
 
m_undefined
 

Detailed Description

template<typename T>
class ENUM_MAP< T >

Definition at line 47 of file property.h.

Constructor & Destructor Documentation

◆ ENUM_MAP()

template<typename T>
ENUM_MAP< T >::ENUM_MAP ( )
inlineprivate

Definition at line 559 of file property.h.

560  {
561  }

Member Function Documentation

◆ Choices()

template<typename T>
wxPGChoices& ENUM_MAP< T >::Choices ( )
inline

◆ Instance()

◆ Map()

template<typename T>
ENUM_MAP& ENUM_MAP< T >::Map ( aValue,
const wxString &  aName 
)
inline

Definition at line 516 of file property.h.

517  {
518  m_choices.Add( aName, static_cast<int>( aValue ) );
519  m_reverseMap[ aName ] = aValue;
520  return *this;
521  }
std::unordered_map< wxString, T > m_reverseMap
Definition: property.h:556
wxPGChoices m_choices
Definition: property.h:555

References ENUM_MAP< T >::m_choices, and ENUM_MAP< T >::m_reverseMap.

Referenced by BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), FOOTPRINT_DESC::FOOTPRINT_DESC(), TRACK_VIA_DESC::TRACK_VIA_DESC(), and PCB_EDIT_FRAME::UpdateUserInterface().

◆ ToEnum()

template<typename T>
const T ENUM_MAP< T >::ToEnum ( const wxString  value)
inline

Definition at line 541 of file property.h.

542  {
543  if( m_reverseMap.count( value ) )
544  return m_reverseMap[ value ];
545  else
546  return m_undefined;
547  }
T m_undefined
Definition: property.h:557
std::unordered_map< wxString, T > m_reverseMap
Definition: property.h:556

References ENUM_MAP< T >::m_reverseMap, and ENUM_MAP< T >::m_undefined.

◆ ToString()

template<typename T>
const wxString& ENUM_MAP< T >::ToString ( value) const
inline

Definition at line 529 of file property.h.

530  {
531  static const wxString s_undef = "UNDEFINED";
532 
533  int idx = m_choices.Index( static_cast<int>( value ) );
534 
535  if( idx >= 0 && idx < (int) m_choices.GetCount() )
536  return m_choices.GetLabel( static_cast<int>( idx ) );
537  else
538  return s_undef;
539  }
wxPGChoices m_choices
Definition: property.h:555

References ENUM_MAP< T >::m_choices.

Referenced by BOARD_INSPECTION_TOOL::reportZoneConnection().

◆ Undefined()

template<typename T>
ENUM_MAP& ENUM_MAP< T >::Undefined ( aValue)
inline

Member Data Documentation

◆ m_choices

template<typename T>
wxPGChoices ENUM_MAP< T >::m_choices
private

Definition at line 555 of file property.h.

Referenced by ENUM_MAP< T >::Choices(), ENUM_MAP< T >::Map(), and ENUM_MAP< T >::ToString().

◆ m_reverseMap

template<typename T>
std::unordered_map<wxString, T> ENUM_MAP< T >::m_reverseMap
private

Definition at line 556 of file property.h.

Referenced by ENUM_MAP< T >::Map(), and ENUM_MAP< T >::ToEnum().

◆ m_undefined

template<typename T>
T ENUM_MAP< T >::m_undefined
private

Definition at line 557 of file property.h.

Referenced by ENUM_MAP< T >::ToEnum(), and ENUM_MAP< T >::Undefined().


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