KiCad PCB EDA Suite
Loading...
Searching...
No Matches
netlist_reader.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) 2012 Jean-Pierre Charras.
5 * Copyright (C) 2013-2017 Wayne Stambaugh <[email protected]>.
6 * Copyright (C) 2012-2021 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#pragma once
27
28#include <boost/ptr_container/ptr_vector.hpp>
29
30#include <macros.h>
31#include <lib_id.h>
32
33
34class COMPONENT;
35class NETLIST;
36class LINE_READER;
37
38
43{
44public:
50 CMP_READER( LINE_READER* aLineReader )
51 {
52 m_lineReader = aLineReader;
53 }
54
56
83 bool Load( NETLIST* aNetlist );
84
85private:
87};
88
89
94{
95public:
96
98 {
99 UNKNOWN = -1,
103
104 // Add new types here. Don't forget to create the appropriate class derived from
105 // NETCLASS_READER and add the entry to the NETLIST_READER::GetNetlistReader()
106 // function.
107 };
108
115 NETLIST* aNetlist,
116 CMP_READER* aFootprintLinkReader = nullptr )
117 {
118 wxASSERT( aLineReader != nullptr );
119
120 m_lineReader = aLineReader;
121 m_footprintReader = aFootprintLinkReader;
122 m_netlist = aNetlist;
124 m_loadNets = true;
125 }
126
127 virtual ~NETLIST_READER();
128
136 static NETLIST_FILE_T GuessNetlistFileType( LINE_READER* aLineReader );
137
150 static NETLIST_READER* GetNetlistReader( NETLIST* aNetlist,
151 const wxString& aNetlistFileName,
152 const wxString& aCompFootprintFileName = wxEmptyString );
153
160 virtual void LoadNetlist() = 0;
161
162protected:
167
170};
171
172
180{
192 COMPONENT* loadComponent( char* aText );
193
213
222 void loadNet( char* aText, COMPONENT* aComponent );
223
224public:
225
227 NETLIST* aNetlist,
228 CMP_READER* aFootprintLinkReader = nullptr ) :
229 NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader )
230 {
231 }
232
253 virtual void LoadNetlist() override;
254};
255
256
261{
262public:
264 NETLIST* aNetlist,
265 CMP_READER* aFootprintLinkReader = nullptr ) :
266 NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader )
267 { }
268
270 { }
271
272 virtual void LoadNetlist() override;
273};
Read a component footprint link file (*.cmp) format.
bool Load(NETLIST *aNetlist)
Read the *.cmp file format contains the component footprint assignments created by CvPcb into aNetlis...
LINE_READER * m_lineReader
The line reader to read.
CMP_READER(LINE_READER *aLineReader)
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:88
Read the new s-expression based KiCad netlist format.
virtual void LoadNetlist() override
Load the contents of the netlist file into aNetlist.
KICAD_NETLIST_READER(LINE_READER *aLineReader, NETLIST *aNetlist, CMP_READER *aFootprintLinkReader=nullptr)
virtual ~KICAD_NETLIST_READER()
Read the KiCad legacy and the old Orcad netlist formats.
LEGACY_NETLIST_READER(LINE_READER *aLineReader, NETLIST *aNetlist, CMP_READER *aFootprintLinkReader=nullptr)
COMPONENT * loadComponent(char *aText)
Read the aLine containing the description of a component from a legacy format netlist and add it to t...
void loadFootprintFilters()
Load the footprint filter section of netlist file.
void loadNet(char *aText, COMPONENT *aComponent)
Function loadNet read a component net description from aText.
virtual void LoadNetlist() override
Read the netlist file in the legacy format into aNetlist.
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
A pure virtual class to derive a specific type of netlist reader from.
static NETLIST_READER * GetNetlistReader(NETLIST *aNetlist, const wxString &aNetlistFileName, const wxString &aCompFootprintFileName=wxEmptyString)
Attempt to determine the net list file type of aNetlistFileName and return the appropriate NETLIST_RE...
static NETLIST_FILE_T GuessNetlistFileType(LINE_READER *aLineReader)
Look at aFileHeaderLine to see if it matches any of the netlist file types it knows about.
NETLIST * m_netlist
The net list to read the file(s) into.
LINE_READER * m_lineReader
The line reader of the netlist.
bool m_loadFootprintFilters
Load the component footprint filters section if true.
virtual void LoadNetlist()=0
Load the contents of the netlist file into aNetlist.
CMP_READER * m_footprintReader
The reader used to load the footprint links. If NULL, footprint links are not read.
NETLIST_READER(LINE_READER *aLineReader, NETLIST *aNetlist, CMP_READER *aFootprintLinkReader=nullptr)
virtual ~NETLIST_READER()
bool m_loadNets
Load the nets section of the netlist file if true.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:241
This file contains miscellaneous commonly used macros and functions.