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
18 * along with this program. If not, see <https://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 // optional callback invoked with the plugin after a successful load, e.g. to extract the
52 // importer's cached library footprints before the plugin is destroyed
53 std::function<void( PCB_IO& )> post_load_hook;
54
55 // if present, will be called with (sheet path, error message) on failure to load sheet
56 std::function<void( const wxString&, const wxString& )> drawing_sheet_error_callback;
57
59 };
60
61 // Will propagate exceptions (e.g. FUTURE_FORMAT_ERROR, IO_ERROR) from the plugin
62 static std::unique_ptr<BOARD> Load( const wxString& aFileName,
64 PROJECT* aProject,
65 const OPTIONS& aOptions );
66
67 // Will propagate exceptions (e.g. FUTURE_FORMAT_ERROR, IO_ERROR) from the plugin
68 static std::unique_ptr<BOARD> Load( const wxString& aFileName,
70 PROJECT* aProject );
71
72 static std::unique_ptr<BOARD> CreateEmptyBoard( PROJECT* aProject );
73
74 static bool SaveBoard( wxString& aFileName, BOARD* aBoard, PCB_IO_MGR::PCB_FILE_T aFormat );
75
76 static bool SaveBoard( wxString& aFileName, BOARD* aBoard );
77
78private:
79 static void initializeLoadedBoard( BOARD* aBoard, const wxString& aFileName,
80 PROJECT* aProject, const OPTIONS& aOptions );
81};
82
83#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:373
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:52
A base class that BOARD loading and saving plugins should derive from.
Definition pcb_io.h:75
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:72
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
std::function< void(PCB_IO &)> post_load_hook
const std::map< std::string, UTF8 > * properties
PROGRESS_REPORTER * progress_reporter