KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_wizard.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <[email protected]>
5 * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25
31#include "footprint_wizard.h"
32
33
35{
36}
37
38
40{
42}
43
44
45std::vector<FOOTPRINT_WIZARD*> FOOTPRINT_WIZARD_LIST::m_FootprintWizards;
46
48{
49 return m_FootprintWizards[aIndex];
50}
51
52
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}
69
70
72{
73 return m_FootprintWizards.size();
74}
75
76
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}
101
102
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}
const char * name
Definition: DXF_plotter.cpp:57
static void register_wizard(FOOTPRINT_WIZARD *aWizard)
A footprint wizard calls this static method when it wants to register itself into the system wizards.
static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
FOOTPRINT_WIZARD system wide static list.
static bool deregister_object(void *aObject)
Unregister an object which builds a wizard.
static FOOTPRINT_WIZARD * GetWizard(const wxString &aName)
The parent class from where any footprint wizard class must derive.
virtual ~FOOTPRINT_WIZARD()
virtual void * GetObject()=0
Get the object from where this wizard constructs.
virtual wxString GetName()=0
void register_wizard()
The standard method of a "FOOTPRINT_WIZARD" to register itself into the FOOTPRINT_WIZARD_LIST singlet...
Class FOOTPRINT_WIZARD and FOOTPRINT_WIZARDS.