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, 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, const wxString& aPinName ) :
75 num( aPinNumber ),
76 netName( aNetName ),
77 pinName( aPinName )
78 {}
79
80 wxString num;
81 wxString netName;
82 wxString pinName;
83};
84
85
90{
91public:
93 m_schematic( aSchematic )
94 {
95 wxASSERT( aSchematic );
96 }
97
98 virtual ~NETLIST_EXPORTER_BASE() = default;
99
103 virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
104 REPORTER& aReporter )
105 {
106 return false;
107 }
108
138 static wxString MakeCommandLine( const wxString& aFormatString, const wxString& aNetlistFile,
139 const wxString& aFinalFile,
140 const wxString& aProjectDirectory );
141
142protected:
152 std::vector<PIN_INFO> CreatePinList( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aSheetPath,
153 bool aKeepUnconnectedPins );
154
164 SCH_SYMBOL* findNextSymbol( EDA_ITEM* aItem, const SCH_SHEET_PATH& aSheetPath );
165
176 void eraseDuplicatePins( std::vector<PIN_INFO>& pins );
177
186 void findAllUnitsOfSymbol( SCH_SYMBOL* aSchSymbol, const SCH_SHEET_PATH& aSheetPath,
187 std::vector<PIN_INFO>& aPins, bool aKeepUnconnectedPins );
188
192
194 std::set<LIB_SYMBOL*, LIB_SYMBOL_LESS_THAN> m_libParts;
195
198};
199
200#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
Define a library symbol object.
Definition lib_symbol.h:85
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:73
Holds all the data relating to one schematic.
Definition schematic.h:88
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:75
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)