KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_loader.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 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef PCBNEW_BOARD_LOADER_H
22#define PCBNEW_BOARD_LOADER_H
23
24#include <functional>
25#include <map>
26#include <memory>
27#include <string>
28
29#include <i18n_utility.h>
30#include <pcb_io/pcb_io_mgr.h>
31
32class BOARD;
33class PCB_IO;
34class PROJECT;
36class REPORTER;
37
38
40{
41public:
42 struct OPTIONS
43 {
44 const std::map<std::string, UTF8>* properties = nullptr;
46 REPORTER* reporter = nullptr;
47
48 // optional callback to configure the plugin, e.g. to set GUI callbacks
49 std::function<void( PCB_IO& )> plugin_configurator;
50
51 // if present, will be called with (sheet path, error message) on failure to load sheet
52 std::function<void( const wxString&, const wxString& )> drawing_sheet_error_callback;
53
55 };
56
57 // Will propagate exceptions (e.g. FUTURE_FORMAT_ERROR, IO_ERROR) from the plugin
58 static std::unique_ptr<BOARD> Load( const wxString& aFileName,
60 PROJECT* aProject,
61 const OPTIONS& aOptions );
62
63 // Will propagate exceptions (e.g. FUTURE_FORMAT_ERROR, IO_ERROR) from the plugin
64 static std::unique_ptr<BOARD> Load( const wxString& aFileName,
66 PROJECT* aProject );
67
68 static std::unique_ptr<BOARD> CreateEmptyBoard( PROJECT* aProject );
69
70 static bool SaveBoard( wxString& aFileName, BOARD* aBoard, PCB_IO_MGR::PCB_FILE_T aFormat );
71
72 static bool SaveBoard( wxString& aFileName, BOARD* aBoard );
73
74private:
75 static void initializeLoadedBoard( BOARD* aBoard, const wxString& aFileName,
76 PROJECT* aProject, const OPTIONS& aOptions );
77};
78
79#endif
static std::unique_ptr< BOARD > CreateEmptyBoard(PROJECT *aProject)
static std::unique_ptr< BOARD > Load(const wxString &aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, PROJECT *aProject, const OPTIONS &aOptions)
static void initializeLoadedBoard(BOARD *aBoard, const wxString &aFileName, PROJECT *aProject, const OPTIONS &aOptions)
static bool SaveBoard(wxString &aFileName, BOARD *aBoard, PCB_IO_MGR::PCB_FILE_T aFormat)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
Definition pcb_io_mgr.h:56
A base class that BOARD loading and saving plugins should derive from.
Definition pcb_io.h:70
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition project.h:66
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Some functions to handle hotkeys in KiCad.
std::function< void(const wxString &, const wxString &)> drawing_sheet_error_callback
std::function< void(PCB_IO &)> plugin_configurator
const std::map< std::string, UTF8 > * properties
PROGRESS_REPORTER * progress_reporter