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 STRING_UTF8_MAP* aProperties = nullptr );
86
115 virtual SCH_SHEET* LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
116 SCH_SHEET* aAppendToMe = nullptr,
117 const STRING_UTF8_MAP* aProperties = nullptr );
118
144 virtual void SaveSchematicFile( const wxString& aFileName, SCH_SHEET* aSheet,
145 SCHEMATIC* aSchematic,
146 const STRING_UTF8_MAP* aProperties = nullptr );
147
164 virtual void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath,
165 const STRING_UTF8_MAP* aProperties = nullptr );
166
186 virtual void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
187 const wxString& aLibraryPath,
188 const STRING_UTF8_MAP* aProperties = nullptr );
189
211 virtual LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aPartName,
212 const STRING_UTF8_MAP* aProperties = nullptr );
213
235 virtual void SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol,
236 const STRING_UTF8_MAP* aProperties = nullptr );
237
256 virtual void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
257 const STRING_UTF8_MAP* aProperties = nullptr );
258
283 virtual void GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const override;
284
288 virtual bool SupportsSubLibraries() const { return false; }
289
302 virtual void GetSubLibraryNames( std::vector<wxString>& aNames ) {}
303
313 virtual void GetAvailableSymbolFields( std::vector<wxString>& aNames ) {}
314
327 virtual void GetDefaultSymbolFields( std::vector<wxString>& aNames )
328 {
329 return GetAvailableSymbolFields( aNames );
330 }
331
340 virtual const wxString& GetError() const;
341
346 virtual void SetLibTable( SYMBOL_LIB_TABLE* aTable ) {}
347
348 //-----</PUBLIC SCH_IO API>------------------------------------------------
349
350
351 /* The compiler writes the "zero argument" constructor for a SCH_IO
352 automatically if you do not provide one. If you decide you need to
353 provide a zero argument constructor of your own design, that is allowed.
354 It must be public, and it is what the SCH_IO_MGR uses. Parameters may be
355 passed into a SCH_IO via the PROPERTIES variable for any of the public
356 API functions which take one.
357 */
358 virtual ~SCH_IO() { }
359
360protected:
361
362 SCH_IO( const wxString& aName ) : IO_BASE( aName )
363 {}
364};
365
366
367#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:75
Base class that schematic file and library loading and saving plugins should derive from.
Definition: sch_io.h:57
virtual void SetLibTable(SYMBOL_LIB_TABLE *aTable)
Some library plugins need to have access to their parent library table.
Definition: sch_io.h:346
virtual void SaveLibrary(const wxString &aFileName, const STRING_UTF8_MAP *aProperties=nullptr)
Definition: sch_io.cpp:62
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:46
virtual int GetModifyHash() const =0
Return the modification hash from the library cache.
virtual void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
Definition: sch_io.cpp:75
SCH_IO(const wxString &aName)
Definition: sch_io.h:362
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:313
virtual void GetLibraryOptions(STRING_UTF8_MAP *aListToAppendTo) const override
Append supported SCH_IO options to aListToAppenTo along with internationalized descriptions.
Definition: sch_io.cpp:125
virtual LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, const STRING_UTF8_MAP *aProperties=nullptr)
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
Definition: sch_io.cpp:101
virtual ~SCH_IO()
Definition: sch_io.h:358
virtual SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr)
Load information from some input file format that this SCH_IO implementation knows about,...
Definition: sch_io.cpp:68
virtual void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
Definition: sch_io.cpp:83
virtual void DeleteSymbol(const wxString &aLibraryPath, const wxString &aSymbolName, const STRING_UTF8_MAP *aProperties=nullptr)
Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.
Definition: sch_io.cpp:117
virtual const wxString & GetError() const
Return an error string to the caller.
Definition: sch_io.cpp:140
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:327
virtual const IO_BASE::IO_FILE_DESC GetSchematicFileDesc() const
Returns schematic file description for the SCH_IO.
Definition: sch_io.cpp:40
virtual void GetSubLibraryNames(std::vector< wxString > &aNames)
Retrieves a list of sub-libraries in this library.
Definition: sch_io.h:302
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
Definition: sch_io.cpp:109
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.
Some functions to handle hotkeys in KiCad.
Container that describes file type info.
Definition: io_base.h:39