KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew/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 (C) 2012 Jean-Pierre Charras.
5 * Copyright (C) 2013-2017 Wayne Stambaugh <[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, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <boost/ptr_container/ptr_vector.hpp>
25
26#include <macros.h>
27#include <lib_id.h>
28
29
30class COMPONENT;
31class NETLIST;
32class LINE_READER;
33
34
38class CMP_READER
39{
40public:
46 CMP_READER( LINE_READER* aLineReader )
47 {
48 m_lineReader = aLineReader;
49 }
50
52
79 bool Load( NETLIST* aNetlist );
80
81private:
83};
84
85
90{
91public:
92
94 {
95 UNKNOWN = -1,
96 ORCAD,
97 LEGACY,
98 KICAD,
99
100 // Add new types here. Don't forget to create the appropriate class derived from
101 // NETCLASS_READER and add the entry to the NETLIST_READER::GetNetlistReader()
102 // function.
103 };
104
111 NETLIST* aNetlist,
112 CMP_READER* aFootprintLinkReader = nullptr )
113 {
114 wxASSERT( aLineReader != nullptr );
115
116 m_lineReader = aLineReader;
117 m_footprintReader = aFootprintLinkReader;
118 m_netlist = aNetlist;
120 m_loadNets = true;
121 }
122
124
133
147 const wxString& aNetlistFileName,
148 const wxString& aCompFootprintFileName = wxEmptyString );
149
156 virtual void LoadNetlist() = 0;
157
158protected:
161 bool m_loadNets;
163
166};
167
168
176{
188 COMPONENT* loadComponent( char* aText );
189
209
218 void loadNet( char* aText, COMPONENT* aComponent );
219
220public:
221
223 NETLIST* aNetlist,
224 CMP_READER* aFootprintLinkReader = nullptr ) :
225 NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader )
226 {
227 }
228
249 virtual void LoadNetlist() override;
250};
251
252
257{
258public:
260 NETLIST* aNetlist,
261 CMP_READER* aFootprintLinkReader = nullptr ) :
262 NETLIST_READER( aLineReader, aNetlist, aFootprintLinkReader )
263 { }
264
266 { }
267
268 virtual void LoadNetlist() override;
269};
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.
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)
Read the KiCad legacy and the old Orcad netlist formats.
LEGACY_NETLIST_READER(LINE_READER *aLineReader, NETLIST *aNetlist, CMP_READER *aFootprintLinkReader=nullptr)
virtual void LoadNetlist() override
Read the netlist file in the legacy format into aNetlist.
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.
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:62
Base class to derive netlist readers from.
virtual ~NETLIST_READER()
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.