KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io.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) 2016 CERN
5 * Copyright (C) 2016-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Wayne Stambaugh <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#ifndef SCH_IO_H_
24#define SCH_IO_H_
25
26#include <io/io_base.h>
27#include <sch_io/sch_io_mgr.h>
28#include <import_export.h>
29#include <map>
30#include <enum_vector.h>
31#include <reporter.h>
32#include <i18n_utility.h>
33#include <wx/arrstr.h>
34
56class SCH_IO : public IO_BASE
57{
58public:
59
60 //-----<PUBLIC SCH_IO API>-------------------------------------------------
61
65 virtual const IO_BASE::IO_FILE_DESC GetSchematicFileDesc() const;
66
71 virtual bool CanReadSchematicFile( const wxString& aFileName ) const;
72
82 virtual int GetModifyHash() const = 0;
83
84 virtual void SaveLibrary( const wxString& aFileName,
85 const std::map<std::string, UTF8>* aProperties = nullptr );
86
115 virtual SCH_SHEET* LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
116 SCH_SHEET* aAppendToMe = nullptr,
117 const std::map<std::string, UTF8>* aProperties = nullptr );
118
144 virtual void SaveSchematicFile( const wxString& aFileName, SCH_SHEET* aSheet,
145 SCHEMATIC* aSchematic,
146 const std::map<std::string, UTF8>* aProperties = nullptr );
147
164 virtual void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath,
165 const std::map<std::string, UTF8>* aProperties = nullptr );
166
186 virtual void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
187 const wxString& aLibraryPath,
188 const std::map<std::string, UTF8>* aProperties = nullptr );
189
211 virtual LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aPartName,
212 const std::map<std::string, UTF8>* aProperties = nullptr );
213
235 virtual void SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol,
236 const std::map<std::string, UTF8>* aProperties = nullptr );
237
256 virtual void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
257 const std::map<std::string, UTF8>* aProperties = nullptr );
258
283 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
284
288 virtual bool SupportsSubLibraries() const { return false; }
289
302 virtual void GetSubLibraryNames( std::vector<wxString>& aNames ) {}
303
313 virtual wxString GetSubLibraryDescription( const wxString& aName ) { return wxEmptyString; }
314
324 virtual void GetAvailableSymbolFields( std::vector<wxString>& aNames ) {}
325
338 virtual void GetDefaultSymbolFields( std::vector<wxString>& aNames )
339 {
340 return GetAvailableSymbolFields( aNames );
341 }
342
351 virtual const wxString& GetError() const;
352
357 virtual void SetLibTable( SYMBOL_LIB_TABLE* aTable ) {}
358
359 //-----</PUBLIC SCH_IO API>------------------------------------------------
360
361
362 /* The compiler writes the "zero argument" constructor for a SCH_IO
363 automatically if you do not provide one. If you decide you need to
364 provide a zero argument constructor of your own design, that is allowed.
365 It must be public, and it is what the SCH_IO_MGR uses. Parameters may be
366 passed into a SCH_IO via the PROPERTIES variable for any of the public
367 API functions which take one.
368 */
369 virtual ~SCH_IO() { }
370
371protected:
372
373 SCH_IO( const wxString& aName ) : IO_BASE( aName )
374 {}
375};
376
377
378#endif // SCH_IO_H_
Define a library symbol object.
Definition: lib_symbol.h:78
Holds all the data relating to one schematic.
Definition: schematic.h:77
Base class that schematic file and library loading and saving plugins should derive from.
Definition: sch_io.h:57
virtual void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
Definition: sch_io.cpp:82
virtual void SetLibTable(SYMBOL_LIB_TABLE *aTable)
Some library plugins need to have access to their parent library table.
Definition: sch_io.h:357
virtual bool SupportsSubLibraries() const
Definition: sch_io.h:288
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
Definition: sch_io.cpp:45
virtual int GetModifyHash() const =0
Return the modification hash from the library cache.
SCH_IO(const wxString &aName)
Definition: sch_io.h:373
virtual SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load information from some input file format that this SCH_IO implementation knows about,...
Definition: sch_io.cpp:67
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
Definition: sch_io.cpp:108
virtual void GetAvailableSymbolFields(std::vector< wxString > &aNames)
Retrieves a list of (custom) field names that are present on symbols in this library.
Definition: sch_io.h:324
virtual void DeleteSymbol(const wxString &aLibraryPath, const wxString &aSymbolName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.
Definition: sch_io.cpp:116
virtual void SaveLibrary(const wxString &aFileName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Definition: sch_io.cpp:61
virtual LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
Definition: sch_io.cpp:100
virtual void GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const override
Append supported SCH_IO options to aListToAppenTo along with internationalized descriptions.
Definition: sch_io.cpp:124
virtual ~SCH_IO()
Definition: sch_io.h:369
virtual void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
Definition: sch_io.cpp:74
virtual const wxString & GetError() const
Return an error string to the caller.
Definition: sch_io.cpp:139
virtual wxString GetSubLibraryDescription(const wxString &aName)
Gets a description of a sublibrary.
Definition: sch_io.h:313
virtual void GetDefaultSymbolFields(std::vector< wxString > &aNames)
Retrieves a list of (custom) field names that should be shown by default for this library in the symb...
Definition: sch_io.h:338
virtual const IO_BASE::IO_FILE_DESC GetSchematicFileDesc() const
Returns schematic file description for the SCH_IO.
Definition: sch_io.cpp:39
virtual void GetSubLibraryNames(std::vector< wxString > &aNames)
Retrieves a list of sub-libraries in this library.
Definition: sch_io.h:302
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
Some functions to handle hotkeys in KiCad.
Container that describes file type info.
Definition: io_base.h:43