KiCad PCB EDA Suite
FOOTPRINT_WIZARD_LIST Class Reference

#include <footprint_wizard.h>

Static Public Member Functions

static void register_wizard (FOOTPRINT_WIZARD *aWizard)
 A footprint wizard calls this static method when it wants to register itself into the system wizards. More...
 
static bool deregister_object (void *aObject)
 Unregister an object which builds a wizard. More...
 
static FOOTPRINT_WIZARDGetWizard (const wxString &aName)
 
static FOOTPRINT_WIZARDGetWizard (int aIndex)
 
static int GetWizardsCount ()
 

Static Private Attributes

static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
 FOOTPRINT_WIZARD system wide static list. More...
 

Detailed Description

Definition at line 156 of file footprint_wizard.h.

Member Function Documentation

◆ deregister_object()

bool FOOTPRINT_WIZARD_LIST::deregister_object ( void *  aObject)
static

Unregister an object which builds a wizard.

Lookup in the vector calling GetObject until find, then removed and deleted.

Parameters
aObjectis the footprint wizard object to be unregistered.

Definition at line 103 of file footprint_wizard.cpp.

104 {
105  int max = GetWizardsCount();
106 
107  for( int ii = 0; ii < max; ii++ )
108  {
109  FOOTPRINT_WIZARD* wizard = GetWizard( ii );
110 
111  if( wizard->GetObject() == aObject )
112  {
113  m_FootprintWizards.erase( m_FootprintWizards.begin() + ii );
114  delete wizard;
115  return true;
116  }
117  }
118 
119  return false;
120 }
static FOOTPRINT_WIZARD * GetWizard(const wxString &aName)
virtual void * GetObject()=0
Get the object from where this wizard constructs.
static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
FOOTPRINT_WIZARD system wide static list.
The parent class from where any footprint wizard class must derive.

References FOOTPRINT_WIZARD::GetObject(), GetWizard(), GetWizardsCount(), and m_FootprintWizards.

Referenced by PYTHON_FOOTPRINT_WIZARD_LIST::deregister_wizard().

◆ GetWizard() [1/2]

FOOTPRINT_WIZARD * FOOTPRINT_WIZARD_LIST::GetWizard ( const wxString &  aName)
static
Parameters
aNameis the footprint wizard name.
Returns
a wizard object by it's name or NULL if it isn't available.

Definition at line 53 of file footprint_wizard.cpp.

54 {
55  int max = GetWizardsCount();
56 
57  for( int i = 0; i<max; i++ )
58  {
59  FOOTPRINT_WIZARD* wizard = GetWizard( i );
60 
61  wxString name = wizard->GetName();
62 
63  if( name.Cmp( aName )==0 )
64  return wizard;
65  }
66 
67  return nullptr;
68 }
static FOOTPRINT_WIZARD * GetWizard(const wxString &aName)
const char * name
Definition: DXF_plotter.cpp:56
virtual wxString GetName()=0
The parent class from where any footprint wizard class must derive.

References FOOTPRINT_WIZARD::GetName(), GetWizardsCount(), and name.

Referenced by deregister_object(), FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint(), FOOTPRINT_WIZARD_FRAME::GetMyWizard(), DIALOG_FOOTPRINT_WIZARD_LIST::initLists(), DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorClick(), and register_wizard().

◆ GetWizard() [2/2]

FOOTPRINT_WIZARD * FOOTPRINT_WIZARD_LIST::GetWizard ( int  aIndex)
static
Parameters
aIndexis the wizard index in list.
Returns
a wizard object by it's number or NULL if it isn't available.

Definition at line 47 of file footprint_wizard.cpp.

48 {
49  return m_FootprintWizards[aIndex];
50 }
static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
FOOTPRINT_WIZARD system wide static list.

References m_FootprintWizards.

◆ GetWizardsCount()

int FOOTPRINT_WIZARD_LIST::GetWizardsCount ( )
static
Returns
the number of wizards available into the system

Definition at line 71 of file footprint_wizard.cpp.

72 {
73  return m_FootprintWizards.size();
74 }
static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
FOOTPRINT_WIZARD system wide static list.

References m_FootprintWizards.

Referenced by deregister_object(), GetWizard(), DIALOG_FOOTPRINT_WIZARD_LIST::initLists(), and register_wizard().

◆ register_wizard()

void FOOTPRINT_WIZARD_LIST::register_wizard ( FOOTPRINT_WIZARD aWizard)
static

A footprint wizard calls this static method when it wants to register itself into the system wizards.

Note
If it is already registered, this function does nothing if an existing wizard with the same name exists, this existing wizard will be unregistered.
Parameters
aWizardis the footprint wizard to be registered.

Definition at line 77 of file footprint_wizard.cpp.

78 {
79  // Search for this entry do not register twice this wizard):
80  for( int ii = 0; ii < GetWizardsCount(); ii++ )
81  {
82  if( aWizard == GetWizard( ii ) ) // Already registered
83  return;
84  }
85 
86  // Search for a wizard with the same name, and remove it if found
87  for( int ii = 0; ii < GetWizardsCount(); ii++ )
88  {
89  FOOTPRINT_WIZARD* wizard = GetWizard( ii );
90 
91  if( wizard->GetName() == aWizard->GetName() )
92  {
93  m_FootprintWizards.erase( m_FootprintWizards.begin() + ii );
94  delete wizard;
95  break;
96  }
97  }
98 
99  m_FootprintWizards.push_back( aWizard );
100 }
static FOOTPRINT_WIZARD * GetWizard(const wxString &aName)
static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
FOOTPRINT_WIZARD system wide static list.
virtual wxString GetName()=0
The parent class from where any footprint wizard class must derive.

References FOOTPRINT_WIZARD::GetName(), GetWizard(), GetWizardsCount(), and m_FootprintWizards.

Referenced by FOOTPRINT_WIZARD::register_wizard().

Member Data Documentation

◆ m_FootprintWizards

std::vector< FOOTPRINT_WIZARD * > FOOTPRINT_WIZARD_LIST::m_FootprintWizards
staticprivate

FOOTPRINT_WIZARD system wide static list.

Definition at line 201 of file footprint_wizard.h.

Referenced by deregister_object(), GetWizard(), GetWizardsCount(), and register_wizard().


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