KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_cadstar_archive.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) 2020 Roberto Fernandez Bautista <[email protected]>
5 * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
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 CADSTAR_ARCHIVE_PLUGIN_H_
22#define CADSTAR_ARCHIVE_PLUGIN_H_
23
24#include <pcb_io/pcb_io.h>
25#include <pcb_io/pcb_io_mgr.h>
27#include <layer_ids.h> // PCB_LAYER_ID
28
29#include <memory>
30
31
33{
34public:
36 {
37 return IO_BASE::IO_FILE_DESC( _HKI( "CADSTAR PCB Archive files" ), { "cpa" } );
38 }
39
40 const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override { return GetBoardFileDesc(); }
41
42 bool CanReadBoard( const wxString& aFileName ) const override;
43 bool CanReadLibrary( const wxString& aFileName ) const override;
44 bool CanReadFootprint( const wxString& aFileName ) const override;
45
46 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
47 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
48
49 std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
50
57 static std::map<wxString, PCB_LAYER_ID> DefaultLayerMappingCallback(
58 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
59
65 void RegisterCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler ) override;
66
67 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
68 bool aBestEfforts, const std::map<std::string, UTF8>* aProperties = nullptr ) override;
69
70 // default implementation of GetEnumeratedFootprint is fine (call FootprintLoad)
71
72 bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
73 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
74
75 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
76 bool aKeepUUID = false,
77 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
78
79 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
80
85 bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
86
89
90private:
92 void ensureLoadedLibrary( const wxString& aLibraryPath );
93
94 typedef std::map<const wxString, std::unique_ptr<FOOTPRINT>> NAME_TO_FOOTPRINT_MAP;
95
96 std::map<wxString, NAME_TO_FOOTPRINT_MAP> m_cache;
97 std::map<wxString, long long> m_timestamps;
98
99 std::vector<FOOTPRINT*> m_loaded_footprints;
101
102 bool checkBoardHeader( const wxString& aFileName ) const;
103};
104
105#endif // CADSTAR_ARCHIVE_PLUGIN_H_
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
Plugin class for import plugins that support remappable layers.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
void ensureLoadedLibrary(const wxString &aLibraryPath)
std::map< const wxString, std::unique_ptr< FOOTPRINT > > NAME_TO_FOOTPRINT_MAP
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
static std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
Return the automapped layers.
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
bool IsLibraryWritable(const wxString &aLibraryPath) override
CADSTAR Plugin is read-only.
void RegisterCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler) override
Register a different handler to be called when mapping of Cadstar to KiCad layers occurs.
std::map< wxString, NAME_TO_FOOTPRINT_MAP > m_cache
bool CanReadFootprint(const wxString &aFileName) const override
Checks if this PCB_IO can read a footprint from specified file or directory.
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
bool checkBoardHeader(const wxString &aFileName) const
std::map< wxString, long long > m_timestamps
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
std::vector< FOOTPRINT * > m_loaded_footprints
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:71
Container for project specific data.
Definition: project.h:64
#define _HKI(x)
std::function< std::map< wxString, PCB_LAYER_ID >(const std::vector< INPUT_LAYER_DESC > &)> LAYER_MAPPING_HANDLER
Pointer to a function that takes a map of source and KiCad layers and returns a re-mapped version.
Container that describes file type info.
Definition: io_base.h:43