KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io.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) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright (C) 2016-2023 Kicad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PCB_IO_H_
26#define PCB_IO_H_
27
28#include <io/io_base.h>
29#include <pcb_io/pcb_io_mgr.h>
30
31#include <cstdint>
32#include <config.h>
33#include <vector>
34#include <wx/arrstr.h>
35#include <i18n_utility.h>
36
37class BOARD;
38class FOOTPRINT;
39class STRING_UTF8_MAP;
40class PROJECT;
42
71class PCB_IO : public IO_BASE
72{
73public:
78 {
79 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
80 }
81
82
87 virtual bool CanReadBoard( const wxString& aFileName ) const;
88
93 virtual bool CanReadFootprint( const wxString& aFileName ) const;
94
98 virtual void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon,
99 wxString aMessage,
100 wxString aAction )> aCallback )
101 { }
102
129 virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
130 const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr );
131
140 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
141
160 virtual void SaveBoard( const wxString& aFileName, BOARD* aBoard,
161 const STRING_UTF8_MAP* aProperties = nullptr );
162
177 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
178 bool aBestEfforts, const STRING_UTF8_MAP* aProperties = nullptr );
179
186 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
187
205 virtual void PrefetchLib( const wxString& aLibraryPath,
206 const STRING_UTF8_MAP* aProperties = nullptr );
207
225 virtual FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
226 const STRING_UTF8_MAP* aProperties = nullptr );
227
249 virtual FOOTPRINT* FootprintLoad( const wxString& aLibraryPath,
250 const wxString& aFootprintName,
251 bool aKeepUUID = false,
252 const STRING_UTF8_MAP* aProperties = nullptr );
253
258 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
259 const wxString& aFootprintName,
260 const STRING_UTF8_MAP* aProperties = nullptr );
261
265 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
266 const STRING_UTF8_MAP* aProperties = nullptr );
267
284 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
285 const STRING_UTF8_MAP* aProperties = nullptr );
286
301 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
302 const STRING_UTF8_MAP* aProperties = nullptr );
303
331 virtual void GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const override;
332
333 virtual ~PCB_IO()
334 {};
335
336protected:
337 PCB_IO( const wxString& aName ) : IO_BASE( aName ),
338 m_board( nullptr ),
339 m_props( nullptr )
340 {}
341
344
347};
348
349#endif // PCB_IO_H_
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:72
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition: pcb_io.h:343
virtual bool CanReadFootprint(const wxString &aFileName) const
Checks if this PCB_IO can read a footprint from specified file or directory.
Definition: pcb_io.cpp:59
const STRING_UTF8_MAP * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition: pcb_io.h:346
virtual FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const STRING_UTF8_MAP *aProperties=nullptr)
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
Definition: pcb_io.cpp:109
virtual long long GetLibraryTimestamp(const wxString &aLibraryPath) const =0
Generate a timestamp representing all the files in the library (including the library directory).
virtual void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aAction)> aCallback)
Registers a KIDIALOG callback for collecting info from the user.
Definition: pcb_io.h:98
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition: pcb_io.cpp:43
virtual void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr)
Return a list of footprint names contained within the library at aLibraryPath.
Definition: pcb_io.cpp:96
PCB_IO(const wxString &aName)
Definition: pcb_io.h:337
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into either ...
Definition: pcb_io.cpp:75
virtual void GetLibraryOptions(STRING_UTF8_MAP *aListToAppendTo) const override
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
Definition: pcb_io.cpp:172
virtual const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
Definition: pcb_io.cpp:131
virtual bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
Check for the existence of a footprint.
Definition: pcb_io.cpp:140
virtual void SaveBoard(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr)
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
Definition: pcb_io.cpp:88
virtual void PrefetchLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
If possible, prefetches the specified library (e.g.
Definition: pcb_io.cpp:104
virtual ~PCB_IO()
Definition: pcb_io.h:333
virtual void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
Delete aFootprintName from the library at aLibraryPath.
Definition: pcb_io.cpp:164
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
Definition: pcb_io.cpp:148
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
Definition: pcb_io.cpp:82
virtual const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Returns board file description for the PCB_IO.
Definition: pcb_io.h:77
virtual void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr)
Write aFootprint to an existing library located at aLibraryPath.
Definition: pcb_io.cpp:156
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition: project.h:62
A name/value tuple with unique names and optional values.
Some functions to handle hotkeys in KiCad.
Container that describes file type info.
Definition: io_base.h:39