KiCad PCB EDA Suite
netlist_exporter.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-2018 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 <kicad_string.h>
30 
31 #include <class_libentry.h>
32 #include <netlist_object.h>
33 #include <lib_pin.h>
34 #include <sch_component.h>
35 #include <sch_text.h>
36 #include <sch_sheet.h>
37 
44 {
45  std::set<wxString> m_set;
46 
47  typedef std::set<wxString>::iterator us_iterator;
48 
49 public:
54  void Clear() { m_set.clear(); }
55 
61  bool Lookup( const wxString& aString )
62  {
63  std::pair<us_iterator, bool> pair = m_set.insert( aString );
64 
65  return !pair.second;
66  }
67 };
68 
74 {
75  // a "less than" test on two LIB_PARTs (.m_name wxStrings)
76  bool operator()( LIB_PART* const& libpart1, LIB_PART* const& libpart2 ) const
77  {
78  // Use case specific GetName() wxString compare
79  return libpart1->GetLibId() < libpart2->GetLibId();
80  }
81 };
82 
88 {
89 protected:
91 
96 
100 
102  std::set<LIB_PART*, LIB_PART_LESS_THAN> m_LibParts;
103 
116  static void sprintPinNetName( wxString& aResult, const wxString& aNetNameFormat,
117  NETLIST_OBJECT* aPin, bool aUseNetcodeAsNetName = false );
118 
126  SCH_COMPONENT* findNextComponentAndCreatePinList( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
127 
128  SCH_COMPONENT* findNextComponent( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
129 
130 
142  void eraseDuplicatePins();
143 
150  bool addPinToComponentPinList( SCH_COMPONENT* Component,
151  SCH_SHEET_PATH* sheet,
152  LIB_PIN* PinEntry );
153 
162  void findAllUnitsOfComponent( SCH_COMPONENT* aComponent,
163  LIB_PART* aEntry,
164  SCH_SHEET_PATH* aSheetPath );
165 
166 public:
167 
174  m_masterList( aMasterList )
175  {
176  wxASSERT( aMasterList );
177  }
178 
180  {
181  delete m_masterList; // I own the list itself in this instance.
182  }
183 
188  virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
189  {
190  return false;
191  }
192 
225  static wxString MakeCommandLine( const wxString& aFormatString,
226  const wxString& aNetlistFile, const wxString& aFinalFile,
227  const wxString& aProjectDirectory
228  );
229 };
230 
231 #endif
Definition of the SCH_SHEET class for Eeschema.
virtual ~NETLIST_EXPORTER()
bool Lookup(const wxString &aString)
Function Lookup returns true if aString already exists in the set, otherwise returns false and adds a...
std::set< wxString > m_set
set of wxStrings already found
UNIQUE_STRINGS m_ReferencesAlreadyFound
Used for "multi parts per package" components, avoids processing a lib component more than once...
NETLIST_EXPORTER(NETLIST_OBJECT_LIST *aMasterList)
Constructor.
std::vector< NETLIST_OBJECT * > NETLIST_OBJECTS
Type NETLIST_OBJECTS is a container referring to (not owning) NETLIST_OBJECTs, which are connected it...
const LIB_ID & GetLibId() const
void Clear()
Function Clear erases the record.
NETLIST_OBJECT_LIST * m_masterList
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
std::set< LIB_PART *, LIB_PART_LESS_THAN > m_LibParts
unique library parts used. LIB_PART items are sorted by names
Class UNIQUE_STRINGS tracks unique wxStrings and is useful in telling if a string has been seen befor...
Class NETLIST_EXPORTER is a abstract class used for the netlist exporters that eeschema supports...
Class LIB_ITEM definition.
Define a library symbol object.
Class SCH_SHEET_PATH.
NETLIST_OBJECTS m_SortedComponentPinList
yes ownership, connected items flat list
Definition the SCH_COMPONENT class for Eeschema.
std::set< wxString >::iterator us_iterator
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
bool operator()(LIB_PART *const &libpart1, LIB_PART *const &libpart2) const
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
virtual bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions)
Function WriteNetlist writes to specified output file.
Definition of the NETLIST_OBJECT class.
Implementation of the label properties dialog.
Struct LIB_PART_LESS_THAN is used by std:set<LIB_PART*> instantiation which uses LIB_PART name as its...