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-2015 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 <class_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->GetName().Cmp( libpart2->GetName() ) < 0;
80  }
81 };
82 
88 {
89 protected:
91 
93 
98 
102 
104  std::set<LIB_PART*, LIB_PART_LESS_THAN> m_LibParts;
105 
106  // share a code generated std::set<void*> to reduce code volume
107  std::set<void*> m_Libraries;
108 
121  static void sprintPinNetName( wxString& aResult, const wxString& aNetNameFormat,
122  NETLIST_OBJECT* aPin, bool aUseNetcodeAsNetName = false );
123 
132 
133  SCH_COMPONENT* findNextComponent( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath );
134 
135 
147  void eraseDuplicatePins();
148 
155  bool addPinToComponentPinList( SCH_COMPONENT* Component,
156  SCH_SHEET_PATH* sheet,
157  LIB_PIN* PinEntry );
158 
167  void findAllUnitsOfComponent( SCH_COMPONENT* aComponent,
168  LIB_PART* aEntry,
169  SCH_SHEET_PATH* aSheetPath );
170 
171 public:
172 
178  m_masterList( aMasterList ),
179  m_libs( aLibs )
180  {
181  }
182 
184  {
185  delete m_masterList; // I own the list itself in this instance.
186  }
187 
192  virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
193  {
194  return false;
195  }
196 
229  static wxString MakeCommandLine( const wxString& aFormatString,
230  const wxString& aTempfile, const wxString& aFinalFile,
231  const wxString& aProjectDirectory
232  );
233 };
234 
235 #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...
static void sprintPinNetName(wxString &aResult, const wxString &aNetNameFormat, NETLIST_OBJECT *aPin, bool aUseNetcodeAsNetName=false)
Function sprintPinNetName formats the net name for aPin using aNetNameFormat into aResult...
void Clear()
Function Clear erases the record.
SCH_COMPONENT * findNextComponent(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
void findAllUnitsOfComponent(SCH_COMPONENT *aComponent, LIB_PART *aEntry, SCH_SHEET_PATH *aSheetPath)
Function findAllUnitsOfComponent is used for "multiple parts per package" components.
NETLIST_OBJECT_LIST * m_masterList
static wxString MakeCommandLine(const wxString &aFormatString, const wxString &aTempfile, const wxString &aFinalFile, const wxString &aProjectDirectory)
Function MakeCommandLine builds up a string that describes a command line for executing a child proce...
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...
std::vector< NETLIST_OBJECT * > NETLIST_OBJECTS
Type NETLIST_OBJECTS is a container referring to (not owning) NETLIST_OBJECTs, which are connected it...
Class NETLIST_EXPORTER is a abstract class used for the netlist exporters that eeschema supports...
const wxString & GetName() const
Class LIB_ITEM definition.
Class LIB_PART defines a library part object.
SCH_COMPONENT * findNextComponentAndCreatePinList(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Function findNextComponentAndCreatePinList finds a component from the DrawList and builds its pin lis...
std::set< void * > m_Libraries
unique libraries used
Class SCH_SHEET_PATH.
Class PART_LIBS is a collection of PART_LIBs.
Definition of the NETLIST_OBJECT class.
NETLIST_OBJECTS m_SortedComponentPinList
no ownership
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:151
PART_LIBS * m_libs
yes ownership, connected items flat list
virtual bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions)
Function WriteNetlist writes to specified output file.
bool addPinToComponentPinList(SCH_COMPONENT *Component, SCH_SHEET_PATH *sheet, LIB_PIN *PinEntry)
Function addPinToComponentPinList adds a new pin description to the pin list m_SortedComponentPinList...
Implementation of the label properties dialog.
NETLIST_EXPORTER(NETLIST_OBJECT_LIST *aMasterList, PART_LIBS *aLibs)
Constructor.
Struct LIB_PART_LESS_THAN is used by std:set instantiation which uses LIB_PART name as its...
void eraseDuplicatePins()
Function eraseDuplicatePins erase duplicate Pins from m_SortedComponentPinList (i.e.