KiCad PCB EDA Suite
netlist_exporter_base.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 <class_libentry.h>
30 #include <lib_pin.h>
31 #include <sch_component.h>
32 #include <sch_text.h>
33 #include <sch_sheet.h>
34 #include <schematic.h>
35 
42 {
43  std::set<wxString> m_set;
44 
45  typedef std::set<wxString>::iterator us_iterator;
46 
47 public:
52  void Clear() { m_set.clear(); }
53 
59  bool Lookup( const wxString& aString )
60  {
61  std::pair<us_iterator, bool> pair = m_set.insert( aString );
62 
63  return !pair.second;
64  }
65 };
66 
72 {
73  // a "less than" test on two LIB_PARTs (.m_name wxStrings)
74  bool operator()( LIB_PART* const& libpart1, LIB_PART* const& libpart2 ) const
75  {
76  // Use case specific GetName() wxString compare
77  return libpart1->GetLibId() < libpart2->GetLibId();
78  }
79 };
80 
81 struct PIN_INFO
82 {
83  PIN_INFO( const wxString& aPinNumber, const wxString& aNetName ) :
84  num( aPinNumber ),
85  netName( aNetName )
86  {}
87 
88  wxString num;
89  wxString netName;
90 };
91 
97 {
98 protected:
102  std::vector<PIN_INFO> m_sortedSymbolPinList;
103 
107 
109  std::set<LIB_PART*, LIB_PART_LESS_THAN> m_libParts;
110 
113 
116 
125  void CreatePinList( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aSheetPath );
126 
134  SCH_COMPONENT* findNextSymbol( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
135 
146  void eraseDuplicatePins();
147 
156  void findAllUnitsOfSymbol( SCH_COMPONENT* aSymbol, LIB_PART* aPart,
157  SCH_SHEET_PATH* aSheetPath );
158 
159 
160 public:
161 
168  m_schematic( aSchematic )
169  {
170  wxASSERT( aSchematic );
172  }
173 
175  {
177  }
178 
183  virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
184  {
185  return false;
186  }
187 
217  static wxString MakeCommandLine( const wxString& aFormatString, const wxString& aNetlistFile,
218  const wxString& aFinalFile, const wxString& aProjectDirectory );
219 };
220 
221 #endif
virtual bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions)
Function WriteNetlist writes to specified output file.
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
void CreatePinList(SCH_COMPONENT *aSymbol, SCH_SHEET_PATH *aSheetPath)
Function findNextSymbolAndCreatePinList finds a symbol from the DrawList and builds its pin list in m...
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:44
std::vector< PIN_INFO > m_sortedSymbolPinList
Used to temporarily store and filter the list of pins of a schematic symbol when generating schematic...
void eraseDuplicatePins()
Function eraseDuplicatePins erase duplicate Pins from m_sortedSymbolPinList (i.e.
NETLIST_EXPORTER_BASE(SCHEMATIC *aSchematic)
Constructor.
PIN_INFO(const wxString &aPinNumber, const wxString &aNetName)
void Clear()
Function Clear erases the record.
void findAllUnitsOfSymbol(SCH_COMPONENT *aSymbol, LIB_PART *aPart, SCH_SHEET_PATH *aSheetPath)
Function findAllUnitsOfSymbol is used for "multiple parts per package" symbols.
std::set< LIB_PART *, LIB_PART_LESS_THAN > m_libParts
unique library parts used. LIB_PART items are sorted by names
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple parts per package" symbols to avoid processing a lib part more than once.
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...
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
UNIQUE_STRINGS tracks unique wxStrings and is useful in telling if a string has been seen before.
SCH_COMPONENT * findNextSymbol(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Checks if the given symbol should be processed for netlisting.
Define a library symbol object.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
NETLIST_EXPORTER_BASE is a abstract class used for the netlist exporters that eeschema supports.
std::set< wxString >::iterator us_iterator
Schematic symbol object.
Definition: sch_component.h:79
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:132
SCH_SHEET_PATH m_savedCurrentSheet
The schematic's CurrentSheet when we entered. Restore on exiting.
bool operator()(LIB_PART *const &libpart1, LIB_PART *const &libpart2) const
Struct LIB_PART_LESS_THAN is used by std:set<LIB_PART*> instantiation which uses LIB_PART name as its...
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:127