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 PROJECT;
41
70class PCB_IO : public IO_BASE
71{
72public:
77 {
78 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
79 }
80
81
86 virtual bool CanReadBoard( const wxString& aFileName ) const;
87
92 virtual bool CanReadFootprint( const wxString& aFileName ) const;
93
97 virtual void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon,
98 wxString aMessage,
99 wxString aAction )> aCallback )
100 { }
101
128 virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
129 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr );
130
139 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
140
159 virtual void SaveBoard( const wxString& aFileName, BOARD* aBoard,
160 const std::map<std::string, UTF8>* aProperties = nullptr );
161
176 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
177 bool aBestEfforts, const std::map<std::string, UTF8>* aProperties = nullptr );
178
185 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
186
204 virtual void PrefetchLib( const wxString& aLibraryPath,
205 const std::map<std::string, UTF8>* aProperties = nullptr );
206
224 virtual FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
225 const std::map<std::string, UTF8>* aProperties = nullptr );
226
248 virtual FOOTPRINT* FootprintLoad( const wxString& aLibraryPath,
249 const wxString& aFootprintName,
250 bool aKeepUUID = false,
251 const std::map<std::string, UTF8>* aProperties = nullptr );
252
257 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
258 const wxString& aFootprintName,
259 const std::map<std::string, UTF8>* aProperties = nullptr );
260
264 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
265 const std::map<std::string, UTF8>* aProperties = nullptr );
266
283 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
284 const std::map<std::string, UTF8>* aProperties = nullptr );
285
300 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
301 const std::map<std::string, UTF8>* aProperties = nullptr );
302
330 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
331
332 virtual ~PCB_IO()
333 {};
334
335protected:
336 PCB_IO( const wxString& aName ) : IO_BASE( aName ),
337 m_board( nullptr ),
338 m_props( nullptr )
339 {}
340
343
345 const std::map<std::string, UTF8>* m_props;
346};
347
348#endif // PCB_IO_H_
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:71
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition: pcb_io.h:342
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:58
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:97
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition: pcb_io.cpp:42
PCB_IO(const wxString &aName)
Definition: pcb_io.h:336
virtual FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
Definition: pcb_io.cpp:108
virtual void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr)
Return a list of footprint names contained within the library at aLibraryPath.
Definition: pcb_io.cpp:95
virtual void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *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:87
virtual void GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const override
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
Definition: pcb_io.cpp:173
virtual void PrefetchLib(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
If possible, prefetches the specified library (e.g.
Definition: pcb_io.cpp:103
virtual ~PCB_IO()
Definition: pcb_io.h:332
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition: pcb_io.h:345
virtual bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Check for the existence of a footprint.
Definition: pcb_io.cpp:141
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
Definition: pcb_io.cpp:81
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *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:74
virtual const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
Definition: pcb_io.cpp:132
virtual const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Returns board file description for the PCB_IO.
Definition: pcb_io.h:76
virtual void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Delete aFootprintName from the library at aLibraryPath.
Definition: pcb_io.cpp:165
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
Definition: pcb_io.cpp:149
virtual void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aFootprint to an existing library located at aLibraryPath.
Definition: pcb_io.cpp:157
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition: project.h:64
Some functions to handle hotkeys in KiCad.
Container that describes file type info.
Definition: io_base.h:43