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 (C) 1992-2023 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 <schematic.h>
30
31class SCH_SYMBOL;
32class LIB_SYMBOL;
33class REPORTER;
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
71
73{
74 PIN_INFO( const wxString& aPinNumber, const wxString& aNetName ) :
75 num( aPinNumber ),
76 netName( aNetName )
77 {}
78
79 wxString num;
80 wxString netName;
81};
82
83
88{
89public:
91 m_schematic( aSchematic )
92 {
93 wxASSERT( aSchematic );
94 }
95
96 virtual ~NETLIST_EXPORTER_BASE() = default;
97
101 virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
102 REPORTER& aReporter )
103 {
104 return false;
105 }
106
136 static wxString MakeCommandLine( const wxString& aFormatString, const wxString& aNetlistFile,
137 const wxString& aFinalFile,
138 const wxString& aProjectDirectory );
139
140protected:
150 std::vector<PIN_INFO> CreatePinList( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aSheetPath,
151 bool aKeepUnconnectedPins );
152
162 SCH_SYMBOL* findNextSymbol( EDA_ITEM* aItem, const SCH_SHEET_PATH& aSheetPath );
163
174 void eraseDuplicatePins( std::vector<PIN_INFO>& pins );
175
184 void findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, const SCH_SHEET_PATH& aSheetPath,
185 std::vector<PIN_INFO>& aPins, bool aKeepUnconnectedPins );
186
190
192 std::set<LIB_SYMBOL*, LIB_SYMBOL_LESS_THAN> m_libParts;
193
196};
197
198#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
Define a library symbol object.
Definition: lib_symbol.h:78
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.
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
NETLIST_EXPORTER_BASE(SCHEMATIC_IFACE *aSchematic)
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.
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.
SCHEMATIC_IFACE * m_schematic
The schematic we're generating a netlist for.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
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:104
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)