KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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
20#ifndef SCH_IO_EASYPC_H_
21#define SCH_IO_EASYPC_H_
22
23#include <sch_io/sch_io.h>
24#include <sch_io/sch_io_mgr.h>
25#include <reporter.h>
26
27#include <map>
28#include <memory>
29
30namespace EASYPC
31{
32class LIBRARY_FILE;
33}
34
35
44class SCH_IO_EASYPC : public SCH_IO
45{
46public:
49
51 {
52 return IO_BASE::IO_FILE_DESC( _HKI( "Easy-PC / DesignSpark schematic and project files" ), { "sch", "prj" } );
53 }
54
56 {
57 return IO_BASE::IO_FILE_DESC( _HKI( "Easy-PC / DesignSpark symbol and component libraries" ),
58 { "ssl", "cml" } );
59 }
60
61 bool CanReadLibrary( const wxString& aFileName ) const override;
62
63 void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath,
64 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
65
66 void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList, const wxString& aLibraryPath,
67 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
68
70 LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aPartName,
71 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
72
73 bool CanReadSchematicFile( const wxString& aFileName ) const override;
74
75 int GetModifyHash() const override { return 0; }
76
77 SCH_SHEET* LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic, SCH_SHEET* aAppendToMe = nullptr,
78 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
79
80 bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
81
82private:
83 struct LIBRARY
84 {
85 long long Timestamp = 0;
86 std::unique_ptr<EASYPC::LIBRARY_FILE> File;
87 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> Symbols;
88 };
89
90 LIBRARY& library( const wxString& aLibraryPath );
91
92 std::unique_ptr<LIB_SYMBOL> convertComponent( const LIBRARY& aLib, const wxString& aLibraryPath,
93 const wxString& aName );
94
95 std::map<wxString, LIBRARY> m_libraries;
96};
97
98#endif // SCH_IO_EASYPC_H_
A library parsed once; items are then served by name without reading the file again.
Define a library symbol object.
Definition lib_symbol.h:114
Holds all the data relating to one schematic.
Definition schematic.h:149
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
const IO_BASE::IO_FILE_DESC GetSchematicFileDesc() const override
Returns schematic file description for the SCH_IO.
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
bool CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_IO can read the specified schematic file.
int GetModifyHash() const override
Return the modification hash from the library cache.
std::unique_ptr< LIB_SYMBOL > convertComponent(const LIBRARY &aLib, const wxString &aLibraryPath, const wxString &aName)
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Converted on first use and owned by the plugin until the file changes.
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
std::map< wxString, LIBRARY > m_libraries
SCH_IO(const wxString &aName)
Definition sch_io.h:406
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
#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< LIB_SYMBOL > > Symbols