![]() |
KiCad PCB EDA Suite
|
Base class that schematic file and library loading and saving plugins should derive from. More...
#include <sch_io_mgr.h>
Classes | |
class | SCH_PLUGIN_RELEASER |
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its destructor. More... | |
Public Member Functions | |
virtual const wxString | GetName () const =0 |
Return a brief hard coded name for this SCH_PLUGIN. More... | |
virtual void | SetReporter (REPORTER *aReporter) |
Set an optional reporter for warnings/errors. More... | |
virtual const wxString | GetFileExtension () const =0 |
Return the file extension for the SCH_PLUGIN. More... | |
virtual const wxString | GetLibraryFileExtension () const =0 |
Return the library file extension for the SCH_PLUGIN object. More... | |
virtual int | GetModifyHash () const =0 |
Return the modification hash from the library cache. More... | |
virtual void | SaveLibrary (const wxString &aFileName, const PROPERTIES *aProperties=nullptr) |
virtual SCH_SHEET * | Load (const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const PROPERTIES *aProperties=nullptr) |
Load information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCH_SHEET or an existing one. More... | |
virtual void | Save (const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr) |
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file. More... | |
virtual void | EnumerateSymbolLib (wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) |
Populate a list of LIB_PART alias names contained within the library aLibraryPath. More... | |
virtual void | EnumerateSymbolLib (std::vector< LIB_PART * > &aSymbolList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) |
Populate a list of LIB_PART aliases contained within the library aLibraryPath. More... | |
virtual LIB_PART * | LoadSymbol (const wxString &aLibraryPath, const wxString &aPartName, const PROPERTIES *aProperties=nullptr) |
Load a LIB_PART object having aPartName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about. More... | |
virtual void | SaveSymbol (const wxString &aLibraryPath, const LIB_PART *aSymbol, const PROPERTIES *aProperties=nullptr) |
Write aSymbol to an existing library located at aLibraryPath. More... | |
virtual void | DeleteSymbol (const wxString &aLibraryPath, const wxString &aSymbolName, const PROPERTIES *aProperties=nullptr) |
Delete the entire LIB_PART associated with aAliasName from the library aLibraryPath. More... | |
virtual void | CreateSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) |
Create a new empty symbol library at aLibraryPath. More... | |
virtual bool | DeleteSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) |
Delete an existing symbol library and returns true if successful, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. More... | |
virtual bool | IsSymbolLibWritable (const wxString &aLibraryPath) |
Return true if the library at aLibraryPath is writable. More... | |
virtual void | SymbolLibOptions (PROPERTIES *aListToAppendTo) const |
Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions. More... | |
virtual bool | CheckHeader (const wxString &aFileName) |
Return true if the first line in aFileName begins with the expected header. More... | |
virtual const wxString & | GetError () const |
Return an error string to the caller. More... | |
virtual | ~SCH_PLUGIN () |
Base class that schematic file and library loading and saving plugins should derive from.
Implementations can provide either Load() or Save() functions, or both. SCH_PLUGINs throw exceptions, so it is best that you wrap your calls to these functions in a try catch block. Plugins throw exceptions because it is illegal for them to have any user interface calls in them whatsoever, i.e. no windowing or screen printing at all.
try { SCH_IO_MGR::Load(...); or SCH_IO_MGR::Save(...); } catch( const IO_ERROR& ioe ) { // grab text from ioe, show in error window. }
Definition at line 151 of file sch_io_mgr.h.
|
inlinevirtual |
Definition at line 466 of file sch_io_mgr.h.
|
virtual |
Return true if the first line in aFileName begins with the expected header.
aFileName | is the name of the file to use as input |
Reimplemented in SCH_LEGACY_PLUGIN, SCH_SEXPR_PLUGIN, SCH_EAGLE_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.
Definition at line 169 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Create a new empty symbol library at aLibraryPath.
It is an error to attempt to create an existing library or to attempt to create on a "read only" location.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aProperties | is an associative array that can be used to tell the library create function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem finding the library, or creating it. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 110 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Delete the entire LIB_PART associated with aAliasName from the library aLibraryPath.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several symbols. |
aSymbolName | is the name of a LIB_PART associated with it's root LIB_PART object to delete from the specified library. |
aProperties | is an associative array that can be used to tell the library delete function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem finding the alias or the library or deleting it. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 102 of file sch_plugin.cpp.
References not_implemented().
Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().
|
virtual |
Delete an existing symbol library and returns true if successful, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.
aLibraryPath | is a locator for the "library", usually a directory or file which will contain symbols. |
aProperties | is an associative array that can be used to tell the library delete implementation function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem deleting an existing library. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 117 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Populate a list of LIB_PART alias names contained within the library aLibraryPath.
aSymbolNameList | is an array to populate with the LIB_PART names associated with the library. |
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects. |
aProperties | is an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if the library cannot be found, the part library cannot be loaded. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 67 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Populate a list of LIB_PART aliases contained within the library aLibraryPath.
aSymbolList | is an array to populate with the LIB_PART pointers associated with the library. |
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects. |
aProperties | is an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if the library cannot be found, the part library cannot be loaded. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 76 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Return an error string to the caller.
This is useful for schematic loaders that can load partial schematics where throwing an exception would be problematic such as the KiCad legacy plugin.
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 177 of file sch_plugin.cpp.
References not_implemented().
Referenced by TEST_SCH_SHEET_LIST_FIXTURE::loadSchematic(), and TEST_NETLISTS_FIXTURE::loadSchematic().
|
pure virtual |
Return the file extension for the SCH_PLUGIN.
Implemented in SCH_EAGLE_PLUGIN, SCH_LEGACY_PLUGIN, SCH_SEXPR_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.
Referenced by SCH_IO_MGR::GetFileExtension().
|
pure virtual |
Return the library file extension for the SCH_PLUGIN object.
Implemented in SCH_EAGLE_PLUGIN, SCH_LEGACY_PLUGIN, SCH_SEXPR_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.
Referenced by SCH_IO_MGR::GetLibraryFileExtension().
|
pure virtual |
Return the modification hash from the library cache.
Implemented in SCH_LEGACY_PLUGIN, SCH_EAGLE_PLUGIN, SCH_SEXPR_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.
|
pure virtual |
Return a brief hard coded name for this SCH_PLUGIN.
Implemented in SCH_EAGLE_PLUGIN, SCH_LEGACY_PLUGIN, SCH_SEXPR_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.
Referenced by not_implemented().
|
virtual |
Return true if the library at aLibraryPath is writable.
(Often system libraries are read only because of where they are installed.)
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several symbols. |
IO_ERROR | if no library at aLibraryPath exists. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 125 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Load information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCH_SHEET or an existing one.
This may be used to load an entire new SCH_SHEET, or to augment an existing one if aAppendToMe is not NULL.
aFileName | is the name of the file to use as input and may be foreign in nature or native in nature. |
aKiway | is the KIWAY object used to access the component libraries loaded by the project. |
aAppendToMe | is an existing SCH_SHEET to append to, but if NULL then this means "do not append, rather load anew". |
aProperties | is an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem loading, and its contents should say what went wrong, using line number and character offsets of the input file if possible. |
Reimplemented in SCH_LEGACY_PLUGIN, SCH_EAGLE_PLUGIN, SCH_SEXPR_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.
Definition at line 51 of file sch_plugin.cpp.
References not_implemented(), and NULL.
Referenced by TEST_SCH_SHEET_LIST_FIXTURE::loadSchematic(), and TEST_NETLISTS_FIXTURE::loadSchematic().
|
virtual |
Load a LIB_PART object having aPartName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several symbols. |
aPartName | is the name of the LIB_PART to load. |
aProperties | is an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if the library cannot be found or read. No exception is thrown in the case where aAliasName cannot be found. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 85 of file sch_plugin.cpp.
References not_implemented(), and NULL.
Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().
|
virtual |
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file.
aFileName | is the name of a file to save to on disk. |
aSheet | is the class SCH_SHEET in memory document tree from which to extract information when writing to aFileName. The caller continues to own the SCHEMATIC, and the plugin should refrain from modifying the SCHEMATIC if possible. |
aSchematic | is the SCHEMATIC object used to access any schematic-wide or project information needed to save the document. |
aProperties | is an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. Set the #PropSaveCurrentSheetOnly property to only save the current sheet. Otherwise, all hierarchical sheets are saved. |
IO_ERROR | if there is a problem saving or exporting. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 59 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 45 of file sch_plugin.cpp.
References not_implemented().
|
virtual |
Write aSymbol to an existing library located at aLibraryPath.
If a LIB_PART by the same name already exists or there are any conflicting alias names, the new LIB_PART will silently overwrite any existing aliases and/or part because libraries cannot have duplicate alias names. It is the responsibility of the caller to check the library for conflicts before saving.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several symbols. |
aSymbol | is what to store in the library. The library is refreshed and the caller must update any LIB_PART pointers that may have changed. |
aProperties | is an associative array that can be used to tell the saver how to save the symbol, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
IO_ERROR | if there is a problem saving. |
Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.
Definition at line 94 of file sch_plugin.cpp.
References not_implemented().
Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().
|
inlinevirtual |
Set an optional reporter for warnings/errors.
Reimplemented in SCH_EAGLE_PLUGIN, SCH_ALTIUM_PLUGIN, and CADSTAR_SCH_ARCHIVE_PLUGIN.
Definition at line 165 of file sch_io_mgr.h.
|
virtual |
Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions.
Options are typically appended so that a derived SCH_PLUGIN can call its base class function by the same name first, thus inheriting options declared there. (Some base class options could pertain to all Symbol*() functions in all derived SCH_PLUGINs.) Note that since aListToAppendTo is a PROPERTIES object, all options will be unique and last guy wins.
aListToAppendTo | holds a tuple of
In the future perhaps aListToAppendTo evolves to something capable of also holding a wxValidator for the cells in said dialog: http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180. This would require a 3 column list, and introducing wx GUI knowledge to SCH_PLUGIN, which has been avoided to date. |
Definition at line 133 of file sch_plugin.cpp.
References _.