KiCad PCB EDA Suite
netlist_exporter.h
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) 1992-2013 jp.charras at wanadoo.fr
5  * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 1992-2019 KiCad Developers
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef NETLIST_EXPORTER_H
27 #define NETLIST_EXPORTER_H
28 
29 #include <kicad_string.h>
30 
31 #include <class_libentry.h>
32 #include <netlist_object.h>
33 #include <lib_pin.h>
34 #include <sch_component.h>
35 #include <sch_text.h>
36 #include <sch_sheet.h>
37 #include <schematic.h>
38 
45 {
46  std::set<wxString> m_set;
47 
48  typedef std::set<wxString>::iterator us_iterator;
49 
50 public:
55  void Clear() { m_set.clear(); }
56 
62  bool Lookup( const wxString& aString )
63  {
64  std::pair<us_iterator, bool> pair = m_set.insert( aString );
65 
66  return !pair.second;
67  }
68 };
69 
75 {
76  // a "less than" test on two LIB_PARTs (.m_name wxStrings)
77  bool operator()( LIB_PART* const& libpart1, LIB_PART* const& libpart2 ) const
78  {
79  // Use case specific GetName() wxString compare
80  return libpart1->GetLibId() < libpart2->GetLibId();
81  }
82 };
83 
84 struct PIN_INFO
85 {
86  PIN_INFO( const wxString& aPinNumber, const wxString& aNetName ) :
87  num( aPinNumber ),
88  netName( aNetName )
89  {}
90 
91  wxString num;
92  wxString netName;
93 };
94 
100 {
101 protected:
106  std::vector<PIN_INFO> m_SortedComponentPinList;
107 
111 
114  std::set<LIB_PART*, LIB_PART_LESS_THAN> m_LibParts;
115 
118 
126  void CreatePinList( SCH_COMPONENT* aItem, SCH_SHEET_PATH* aSheetPath );
127 
135  SCH_COMPONENT* findNextComponent( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
136 
148  void eraseDuplicatePins();
149 
158  void findAllUnitsOfComponent( SCH_COMPONENT* aComponent,
159  LIB_PART* aEntry,
160  SCH_SHEET_PATH* aSheetPath );
161 
162 
163 public:
164 
170  NETLIST_EXPORTER( SCHEMATIC* aSchematic ) :
171  m_schematic( aSchematic )
172  {
173  wxASSERT( aSchematic );
174  }
175 
177  {
178  }
179 
184  virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
185  {
186  return false;
187  }
188 
221  static wxString MakeCommandLine( const wxString& aFormatString,
222  const wxString& aNetlistFile, const wxString& aFinalFile,
223  const wxString& aProjectDirectory
224  );
225 };
226 
227 #endif
virtual ~NETLIST_EXPORTER()
bool Lookup(const wxString &aString)
Function Lookup returns true if aString already exists in the set, otherwise returns false and adds a...
LIB_ID GetLibId() const override
std::set< wxString > m_set
set of wxStrings already found
UNIQUE_STRINGS m_ReferencesAlreadyFound
Used for "multi parts per package" components, avoids processing a lib component more than once.
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
PIN_INFO(const wxString &aPinNumber, const wxString &aNetName)
void Clear()
Function Clear erases the record.
static wxString MakeCommandLine(const wxString &aFormatString, const wxString &aNetlistFile, const wxString &aFinalFile, const wxString &aProjectDirectory)
Function MakeCommandLine builds up a string that describes a command line for executing a child proce...
SCH_COMPONENT * findNextComponent(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Checks if the given component should be processed for netlisting.
void findAllUnitsOfComponent(SCH_COMPONENT *aComponent, LIB_PART *aEntry, SCH_SHEET_PATH *aSheetPath)
Function findAllUnitsOfComponent is used for "multiple parts per package" components.
std::set< LIB_PART *, LIB_PART_LESS_THAN > m_LibParts
unique library parts used.
UNIQUE_STRINGS tracks unique wxStrings and is useful in telling if a string has been seen before.
NETLIST_EXPORTER is a abstract class used for the netlist exporters that eeschema supports.
void CreatePinList(SCH_COMPONENT *aItem, SCH_SHEET_PATH *aSheetPath)
Function findNextComponentAndCreatePinList finds a component from the DrawList and builds its pin lis...
Define a library symbol object.
std::vector< PIN_INFO > m_SortedComponentPinList
Used to temporarily store and filter the list of pins of a schematic component when generating schema...
SCH_SHEET_PATH.
NETLIST_EXPORTER(SCHEMATIC *aSchematic)
Constructor.
wxString netName
std::set< wxString >::iterator us_iterator
Schematic symbol object.
Definition: sch_component.h:88
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
virtual bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions)
Function WriteNetlist writes to specified output file.
Definition of the NETLIST_OBJECT class.
bool operator()(LIB_PART *const &libpart1, LIB_PART *const &libpart2) const
wxString num
Struct LIB_PART_LESS_THAN is used by std:set<LIB_PART*> instantiation which uses LIB_PART name as its...
void eraseDuplicatePins()
Function eraseDuplicatePins erase duplicate Pins from m_SortedComponentPinList (i....