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 The 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,
130 PROJECT* aProject = nullptr );
131
140 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
141
160 virtual void SaveBoard( const wxString& aFileName, BOARD* aBoard,
161 const std::map<std::string, UTF8>* aProperties = nullptr );
162
177 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
178 bool aBestEfforts,
179 const std::map<std::string, UTF8>* aProperties = nullptr );
180
187 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
188
206 virtual FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
207 const std::map<std::string, UTF8>* aProperties = nullptr );
208
230 virtual FOOTPRINT* FootprintLoad( const wxString& aLibraryPath,
231 const wxString& aFootprintName,
232 bool aKeepUUID = false,
233 const std::map<std::string, UTF8>* aProperties = nullptr );
234
239 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
240 const wxString& aFootprintName,
241 const std::map<std::string, UTF8>* aProperties = nullptr );
242
246 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
247 const std::map<std::string, UTF8>* aProperties = nullptr );
248
265 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
266 const std::map<std::string, UTF8>* aProperties = nullptr );
267
282 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
283 const std::map<std::string, UTF8>* aProperties = nullptr );
284
312 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
313
314 virtual ~PCB_IO()
315 {};
316
317protected:
318 PCB_IO( const wxString& aName ) : IO_BASE( aName ),
319 m_board( nullptr ),
320 m_props( nullptr )
321 {}
322
325
327 const std::map<std::string, UTF8>* m_props;
328};
329
330#endif // PCB_IO_H_
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:295
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:324
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:318
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:103
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:168
virtual ~PCB_IO()
Definition: pcb_io.h:314
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition: pcb_io.h:327
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:136
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:127
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:160
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:144
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:152
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