KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef NETLIST_EXPORTER_H
23#define NETLIST_EXPORTER_H
24
25#include <schematic.h>
26
27class SCH_SYMBOL;
28class LIB_SYMBOL;
29class REPORTER;
30
35{
36public:
40 void Clear() { m_set.clear(); }
41
46 bool Lookup( const wxString& aString )
47 {
48 std::pair<us_iterator, bool> pair = m_set.insert( aString );
49
50 return !pair.second;
51 }
52
53 std::set<wxString> m_set;
54
55 typedef std::set<wxString>::iterator us_iterator;
56};
57
62{
63 // a "less than" test on two LIB_SYMBOLs (.m_name wxStrings)
64 bool operator()( LIB_SYMBOL* const& libsymbol1, LIB_SYMBOL* const& libsymbol2 ) const;
65};
66
67
69{
70 PIN_INFO( const wxString& aPinNumber, const wxString& aNetName, const wxString& aPinName ) :
71 num( aPinNumber ),
72 netName( aNetName ),
73 pinName( aPinName )
74 {}
75
76 wxString num;
77 wxString netName;
78 wxString pinName;
79};
80
81
86{
87public:
89 m_schematic( aSchematic )
90 {
91 wxASSERT( aSchematic );
92 }
93
94 virtual ~NETLIST_EXPORTER_BASE() = default;
95
99 virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
100 REPORTER& aReporter )
101 {
102 return false;
103 }
104
134 static wxString MakeCommandLine( const wxString& aFormatString, const wxString& aNetlistFile,
135 const wxString& aFinalFile,
136 const wxString& aProjectDirectory );
137
138protected:
148 std::vector<PIN_INFO> CreatePinList( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aSheetPath,
149 bool aKeepUnconnectedPins );
150
160 SCH_SYMBOL* findNextSymbol( EDA_ITEM* aItem, const SCH_SHEET_PATH& aSheetPath );
161
172 void eraseDuplicatePins( std::vector<PIN_INFO>& pins );
173
182 void findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, const SCH_SHEET_PATH& aSheetPath,
183 std::vector<PIN_INFO>& aPins, bool aKeepUnconnectedPins );
184
188
190 std::set<LIB_SYMBOL*, LIB_SYMBOL_LESS_THAN> m_libParts;
191
194};
195
196#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
Define a library symbol object.
Definition lib_symbol.h:79
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
virtual bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter)
Write to specified output file.
std::vector< PIN_INFO > CreatePinList(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheetPath, bool aKeepUnconnectedPins)
Find a symbol from the DrawList and builds its pin list.
virtual ~NETLIST_EXPORTER_BASE()=default
void findAllUnitsOfSymbol(SCH_SYMBOL *aSchSymbol, const SCH_SHEET_PATH &aSheetPath, std::vector< PIN_INFO > &aPins, bool aKeepUnconnectedPins)
Find all units for symbols with multiple symbols per package.
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath)
Check if the given symbol should be processed for netlisting.
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THAN > m_libParts
unique library symbols used. LIB_SYMBOL items are sorted by names
void eraseDuplicatePins(std::vector< PIN_INFO > &pins)
Erase duplicate pins.
NETLIST_EXPORTER_BASE(SCHEMATIC *aSchematic)
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
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.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
Holds all the data relating to one schematic.
Definition schematic.h:90
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:69
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, const wxString &aPinName)