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 <[email protected]>
6 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
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 <lib_pin.h>
30#include <sch_symbol.h>
31#include <sch_text.h>
32#include <sch_sheet.h>
33#include <schematic.h>
34
39{
40public:
44 void Clear() { m_set.clear(); }
45
50 bool Lookup( const wxString& aString )
51 {
52 std::pair<us_iterator, bool> pair = m_set.insert( aString );
53
54 return !pair.second;
55 }
56
57 std::set<wxString> m_set;
58
59 typedef std::set<wxString>::iterator us_iterator;
60};
61
66{
67 // a "less than" test on two LIB_SYMBOLs (.m_name wxStrings)
68 bool operator()( LIB_SYMBOL* const& libsymbol1, LIB_SYMBOL* const& libsymbol2 ) const
69 {
70 // Use case specific GetName() wxString compare
71 return libsymbol1->GetLibId() < libsymbol2->GetLibId();
72 }
73};
74
75
77{
78 PIN_INFO( const wxString& aPinNumber, const wxString& aNetName ) :
79 num( aPinNumber ),
80 netName( aNetName )
81 {}
82
83 wxString num;
84 wxString netName;
85};
86
87
92{
93public:
99 m_schematic( aSchematic )
100 {
101 wxASSERT( aSchematic );
102 }
103
104 virtual ~NETLIST_EXPORTER_BASE() = default;
105
109 virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
110 REPORTER& aReporter )
111 {
112 return false;
113 }
114
144 static wxString MakeCommandLine( const wxString& aFormatString, const wxString& aNetlistFile,
145 const wxString& aFinalFile,
146 const wxString& aProjectDirectory );
147
148protected:
158 void CreatePinList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPath,
159 bool aKeepUnconnectedPins );
160
170 SCH_SYMBOL* findNextSymbol( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
171
182 void eraseDuplicatePins();
183
193 void findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, SCH_SHEET_PATH* aSheetPath,
194 bool aKeepUnconnectedPins );
195
199 std::vector<PIN_INFO> m_sortedSymbolPinList;
200
204
206 std::set<LIB_SYMBOL*, LIB_SYMBOL_LESS_THAN> m_libParts;
207
210};
211
212#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
Define a library symbol object.
Definition: lib_symbol.h:98
LIB_ID GetLibId() const override
Definition: lib_symbol.h:139
An abstract class used for the netlist exporters that Eeschema supports.
virtual bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter)
Write to specified output file.
void CreatePinList(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aSheetPath, bool aKeepUnconnectedPins)
Find a symbol from the DrawList and builds its pin list in m_sortedSymbolPinList.
virtual ~NETLIST_EXPORTER_BASE()=default
void eraseDuplicatePins()
Erase duplicate pins from m_sortedSymbolPinList (i.e.
NETLIST_EXPORTER_BASE(SCHEMATIC_IFACE *aSchematic)
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THAN > m_libParts
unique library symbols used. LIB_SYMBOL items are sorted by names
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Check if the given symbol should be processed for netlisting.
static wxString MakeCommandLine(const wxString &aFormatString, const wxString &aNetlistFile, const wxString &aFinalFile, const wxString &aProjectDirectory)
Build up a string that describes a command line for executing a child process.
void findAllUnitsOfSymbol(SCH_SYMBOL *aSchSymbol, SCH_SHEET_PATH *aSheetPath, bool aKeepUnconnectedPins)
Find all units for symbols with multiple symbols per package.
SCHEMATIC_IFACE * m_schematic
The schematic we're generating a netlist for.
std::vector< PIN_INFO > m_sortedSymbolPinList
Used to temporarily store and filter the list of pins of a schematic symbol when generating schematic...
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:80
Track unique wxStrings and is useful in telling if a string has been seen before.
std::set< wxString > m_set
set of wxStrings already found
void Clear()
Erase the record.
bool Lookup(const wxString &aString)
std::set< wxString >::iterator us_iterator
Used by std:set<LIB_SYMBOL*> instantiation which uses LIB_SYMBOL name as its key.
bool operator()(LIB_SYMBOL *const &libsymbol1, LIB_SYMBOL *const &libsymbol2) const
PIN_INFO(const wxString &aPinNumber, const wxString &aNetName)