KiCad PCB EDA Suite
class_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 <miguelangel@ajo.es>
5  * Copyright (C) 2013 KiCad Developers, see CHANGELOG.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 "class_footprint_wizard.h"
32 
33 
35 {
36 }
37 
38 
40 {
42 }
43 
44 
45 std::vector<FOOTPRINT_WIZARD*> FOOTPRINT_WIZARDS::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 NULL;
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 }
static FOOTPRINT_WIZARD * GetWizard(wxString aName)
Function GetWizard.
virtual void * GetObject()=0
Function GetObject This method gets the pointer to the object from where this wizard constructs...
void register_wizard()
Function register_wizard It's the standard method of a "FOOTPRINT_WIZARD" to register itself into the...
Class PCBNEW_FOOTPRINT_WIZARDS.
static void register_wizard(FOOTPRINT_WIZARD *aWizard)
Function register_wizard A footprint wizard calls this static method when it wants to register itself...
static int GetWizardsCount()
Function GetWizardsCount.
#define max(a, b)
Definition: auxiliary.h:86
static bool deregister_object(void *aObject)
Function deregister_object Anyone calls this method to deregister an object which builds a wizard...
virtual wxString GetName()=0
Function GetName.
const char * name
Class FOOTPRINT_WIZARD This is the parent class from where any footprint wizard class must derive...
static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
FOOTPRINT_WIZARD system wide static list.