KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_easypc.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 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
24
25#ifndef PCB_IO_EASYPC_H_
26#define PCB_IO_EASYPC_H_
27
28#include <map>
29#include <memory>
30
31#include <pcb_io/pcb_io.h>
32#include <pcb_io/pcb_io_mgr.h>
34
35namespace EASYPC
36{
37class LIBRARY_FILE;
38}
39
40
42{
43public:
45 ~PCB_IO_EASYPC() override;
46
48 {
49 return IO_BASE::IO_FILE_DESC( _HKI( "Easy-PC and DesignSpark PCB files" ), { "pcb" } );
50 }
51
53 {
54 return IO_BASE::IO_FILE_DESC( _HKI( "Easy-PC and DesignSpark PCB symbol libraries" ), { "psl" } );
55 }
56
57 bool CanReadBoard( const wxString& aFileName ) const override;
58 bool CanReadLibrary( const wxString& aFileName ) const override;
59 bool CanReadFootprint( const wxString& aFileName ) const override { return CanReadLibrary( aFileName ); }
60
61 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
62
63 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath, bool aBestEfforts,
64 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
65
66 std::unique_ptr<FOOTPRINT> FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
67 bool aKeepUUID = false,
68 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
69
70 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
71 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
72
73 bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
74 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
75
76 bool CachesEnumeratedFootprints() const override { return true; }
77
78 bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
79
80 wxString GetImportedDesignRules() const override { return m_importedDesignRules; }
81
82protected:
83 void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
84 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
85
86private:
87 struct LIBRARY
88 {
89 long long Timestamp = 0;
90 std::unique_ptr<EASYPC::LIBRARY_FILE> File;
91 std::map<wxString, std::unique_ptr<FOOTPRINT>> Footprints;
92 };
93
95 LIBRARY& library( const wxString& aLibraryPath );
96
98 std::map<wxString, LIBRARY> m_libraries;
99};
100
101#endif // PCB_IO_EASYPC_H_
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
A library parsed once; items are then served by name without reading the file again.
Plugin class for import plugins that support remappable layers.
bool CanReadBoard(const wxString &aFileName) const override
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
~PCB_IO_EASYPC() override
wxString GetImportedDesignRules() const override
Return custom DRC rules generated while importing the most recent board.
bool CanReadFootprint(const wxString &aFileName) const override
Check if this PCB_IO can read a footprint from specified file or 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 CachesEnumeratedFootprints() const override
Return true if GetEnumeratedFootprint() returns a borrowed pointer from an internal cache.
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Return board file description for the PCB_IO.
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management i...
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Parse aFileName into aBoard.
wxString m_importedDesignRules
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
std::unique_ptr< 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...
std::map< wxString, LIBRARY > m_libraries
PCB_IO(const wxString &aName)
Definition pcb_io.h:372
Container for project specific data.
Definition project.h:63
#define _HKI(x)
Definition page_info.cpp:40
Container that describes file type info.
Definition io_base.h:43
std::unique_ptr< EASYPC::LIBRARY_FILE > File
std::map< wxString, std::unique_ptr< FOOTPRINT > > Footprints