KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 SCH_IO_CADSTAR_ARCHIVE_H_
22#define SCH_IO_CADSTAR_ARCHIVE_H_
23
24#include <map>
25#include <sch_io/sch_io.h>
26#include <sch_io/sch_io_mgr.h>
27#include <reporter.h>
28#include <lib_symbol.h>
30
31
32class SCH_SHEET;
33class SCH_SCREEN;
34
36{
37public:
38 SCH_IO_CADSTAR_ARCHIVE() : SCH_IO( wxS( "CADSTAR Schematic Archive" ) ),
40 {
42 }
43
45
46 void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; }
47
48 void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override
49 {
50 m_progressReporter = aReporter;
51 }
52
54 {
55 return IO_BASE::IO_FILE_DESC( _HKI( "CADSTAR Schematic Archive files" ),
57 }
58
60 {
61 return IO_BASE::IO_FILE_DESC( _HKI( "CADSTAR Parts Library files" ),
63 }
64
65 bool CanReadLibrary( const wxString& aFileName ) const override;
66
67 int GetModifyHash() const override;
68
69 SCH_SHEET* LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
70 SCH_SHEET* aAppendToMe = nullptr,
71 const STRING_UTF8_MAP* aProperties = nullptr ) override;
72
73 void EnumerateSymbolLib( wxArrayString& aSymbolNameList,
74 const wxString& aLibraryPath,
75 const STRING_UTF8_MAP* aProperties = nullptr ) override;
76
77 void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
78 const wxString& aLibraryPath,
79 const STRING_UTF8_MAP* aProperties = nullptr ) override;
80
81 LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
82 const STRING_UTF8_MAP* aProperties = nullptr ) override;
83
84 void GetAvailableSymbolFields( std::vector<wxString>& aNames ) override;
85
86
87 // Writing to CADSTAR libraries is not supported
88 bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
89
90 void GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const override;
91
92private:
93 // Symbol caching
94 void ensureLoadedLibrary( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties );
95
96 typedef std::map<const wxString, std::unique_ptr<LIB_SYMBOL>> NAME_TO_SYMBOL_MAP;
97
100 wxString m_cachePath;
101 wxFileName m_cachecsafn;
103};
104
105#endif // SCH_IO_CADSTAR_ARCHIVE_H_
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
Definition: io_base.h:215
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Definition: io_base.h:218
Define a library symbol object.
Definition: lib_symbol.h:77
A progress reporter interface for use in multi-threaded environments.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
Holds all the data relating to one schematic.
Definition: schematic.h:75
void SetProgressReporter(PROGRESS_REPORTER *aReporter) override
Set an optional progress reporter.
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
int GetModifyHash() const override
Return the modification hash from the library cache.
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
std::map< const wxString, std::unique_ptr< LIB_SYMBOL > > NAME_TO_SYMBOL_MAP
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
void ensureLoadedLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties)
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
void GetAvailableSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that are present on symbols in this library.
void GetLibraryOptions(STRING_UTF8_MAP *aListToAppendTo) const override
Append supported SCH_IO options to aListToAppenTo along with internationalized descriptions.
const IO_BASE::IO_FILE_DESC GetSchematicFileDesc() const override
Returns schematic file description for the SCH_IO.
void SetReporter(REPORTER *aReporter) override
Set an optional reporter for warnings/errors.
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.
NAME_TO_SYMBOL_MAP m_libCache
Base class that schematic file and library loading and saving plugins should derive from.
Definition: sch_io.h:57
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
A name/value tuple with unique names and optional values.
static REPORTER & GetInstance()
Definition: reporter.cpp:212
#define _HKI(x)
static const std::string CadstarPartsLibraryFileExtension
static const std::string CadstarSchematicFileExtension
Container that describes file type info.
Definition: io_base.h:40
Definition of file extensions used in Kicad.