KiCad PCB EDA Suite
Loading...
Searching...
No Matches
common/netlist_reader/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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <macros.h>
27#include <lib_id.h>
29
30
31class LINE_READER;
32
33
38{
39public:
45 CMP_READER( LINE_READER* aLineReader )
46 {
47 m_lineReader = aLineReader;
48 }
49
51
78 bool Load( NETLIST* aNetlist );
79
80private:
82};
83
84
93{
94public:
95
97 {
98 UNKNOWN = -1,
102
103 // Add new types here. Don't forget to create the appropriate class derived from
104 // NETCLASS_READER and add the entry to the NETLIST_READER::GetNetlistReader()
105 // function.
106 };
107
114 NETLIST* aNetlist,
115 CMP_READER* aFootprintLinkReader = nullptr )
116 {
117 wxASSERT( aLineReader != nullptr );
118
119 m_lineReader = aLineReader;
120 m_footprintReader = aFootprintLinkReader;
121 m_netlist = aNetlist;
123 m_loadNets = true;
124 }
125
126 virtual ~NETLIST_READER();
127
135 static NETLIST_FILE_T GuessNetlistFileType( LINE_READER* aLineReader );
136
149 static NETLIST_READER* GetNetlistReader( NETLIST* aNetlist,
150 const wxString& aNetlistFileName,
151 const wxString& aCompFootprintFileName = wxEmptyString );
152
159 virtual void LoadNetlist() = 0;
160
161protected:
166
169};
170
171
179{
191 COMPONENT* loadComponent( char* aText );
192
212
221 void loadNet( char* aText, COMPONENT* aComponent );
222
223public:
224
226 NETLIST* aNetlist,
227 CMP_READER* aFootprintLinkReader = nullptr ) :
228 NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader )
229 {
230 }
231
252 virtual void LoadNetlist() override;
253};
254
255
260{
261public:
263 NETLIST* aNetlist,
264 CMP_READER* aFootprintLinkReader = nullptr ) :
265 NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader )
266 { }
267
269 { }
270
271 virtual void LoadNetlist() override;
272};
Read a component footprint link file (*.cmp) format.
LINE_READER * m_lineReader
The line reader to read.
bool Load(NETLIST *aNetlist)
Read the *.cmp file format contains the component footprint assignments created by CvPcb into aNetlis...
CMP_READER(LINE_READER *aLineReader)
Store all of the related component information found in a netlist.
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)
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:94
Base class to derive netlist readers 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.
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.
LINE_READER * m_lineReader
The line reader of the netlist.
NETLIST_READER(LINE_READER *aLineReader, NETLIST *aNetlist, CMP_READER *aFootprintLinkReader=nullptr)
NETLIST * m_netlist
The net list to read the file(s) into.
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.
This file contains miscellaneous commonly used macros and functions.