![]() |
KiCad PCB EDA Suite
|
A PLUGIN derivation for saving and loading Geda PCB files. More...
#include <gpcb_plugin.h>
Public Member Functions | |
const wxString | PluginName () const override |
Return a brief hard coded name for this PLUGIN. More... | |
const wxString | GetFileExtension () const override |
Returns the file extension for the PLUGIN. More... | |
void | FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=nullptr) override |
Return a list of footprint names contained within the library at aLibraryPath. More... | |
const FOOTPRINT * | GetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override |
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management. More... | |
FOOTPRINT * | FootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr) override |
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about. More... | |
void | FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override |
Delete aFootprintName from the library at aLibraryPath. More... | |
bool | FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override |
Delete an existing footprint library and returns true, 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... | |
long long | GetLibraryTimestamp (const wxString &aLibraryPath) const override |
Generate a timestamp representing all the files in the library (including the library directory). More... | |
bool | IsFootprintLibWritable (const wxString &aLibraryPath) override |
Return true if the library at aLibraryPath is writable. More... | |
GPCB_PLUGIN () | |
GPCB_PLUGIN (int aControlFlags) | |
~GPCB_PLUGIN () | |
virtual BOARD * | Load (const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) |
Load information from some input file format that this PLUGIN implementation knows about into either a new BOARD or an existing one. More... | |
virtual std::vector< FOOTPRINT * > | GetImportedCachedLibraryFootprints () |
Return a container with the cached library footprints generated in the last call to Load. More... | |
virtual void | Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr) |
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be used to write a portion of aBoard to a special kind of export file. More... | |
virtual void | PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) |
If possible, prefetches the specified library (e.g. More... | |
virtual bool | FootprintExists (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) |
Check for the existence of a footprint. More... | |
virtual void | FootprintSave (const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const PROPERTIES *aProperties=nullptr) |
Write aFootprint to an existing library located at aLibraryPath. More... | |
virtual void | FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) |
Create a new empty footprint library at aLibraryPath empty. More... | |
virtual void | FootprintLibOptions (PROPERTIES *aListToAppendTo) const |
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More... | |
Protected Attributes | |
wxString | m_error |
for throwing exceptions More... | |
const PROPERTIES * | m_props |
passed via Save() or Load(), no ownership, may be NULL. More... | |
GPCB_FPL_CACHE * | m_cache |
Footprint library cache. More... | |
int | m_ctl |
LINE_READER * | m_reader |
no ownership here. More... | |
wxString | m_filename |
for saves only, name is in m_reader for loads More... | |
Private Member Functions | |
void | validateCache (const wxString &aLibraryPath, bool checkModified=true) |
const FOOTPRINT * | getFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified) |
void | init (const PROPERTIES *aProperties) |
Friends | |
class | GPCB_FPL_CACHE |
A PLUGIN derivation for saving and loading Geda PCB files.
Definition at line 46 of file gpcb_plugin.h.
GPCB_PLUGIN::GPCB_PLUGIN | ( | ) |
Definition at line 820 of file gpcb_plugin.cpp.
GPCB_PLUGIN::GPCB_PLUGIN | ( | int | aControlFlags | ) |
Definition at line 829 of file gpcb_plugin.cpp.
GPCB_PLUGIN::~GPCB_PLUGIN | ( | ) |
|
overridevirtual |
Delete aFootprintName from the library at aLibraryPath.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aFootprintName | is the name of a footprint 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 footprint or the library, or deleting it. |
Reimplemented from PLUGIN.
Definition at line 950 of file gpcb_plugin.cpp.
References _, Format(), init(), GPCB_FPL_CACHE::IsWritable(), m_cache, GPCB_FPL_CACHE::Remove(), THROW_IO_ERROR, and validateCache().
|
overridevirtual |
Return a list of footprint names contained within the library at aLibraryPath.
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 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. |
aFootprintNames | is the array of available footprint names inside a library. |
aBestEfforts | if true, don't throw on errors, just return an empty list. |
IO_ERROR | if the library cannot be found, or footprint cannot be loaded. |
Reimplemented from PLUGIN.
Definition at line 862 of file gpcb_plugin.cpp.
References _, Format(), FROM_UTF8(), GPCB_FPL_CACHE::GetFootprints(), init(), m_cache, THROW_IO_ERROR, validateCache(), and IO_ERROR::What().
|
virtualinherited |
Check for the existence of a footprint.
Reimplemented in PCB_PLUGIN.
Definition at line 89 of file plugin.cpp.
References PLUGIN::FootprintLoad().
|
virtualinherited |
Create a new empty footprint library at aLibraryPath empty.
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 PCB_PLUGIN.
Definition at line 124 of file plugin.cpp.
References not_implemented().
|
overridevirtual |
Delete an existing footprint library and returns true, 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 footprints. |
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 from PLUGIN.
Definition at line 969 of file gpcb_plugin.cpp.
References _, Format(), GPCB_FPL_CACHE::GetPath(), KiCadFootprintFileExtension, m_cache, THROW_IO_ERROR, and traceGedaPcbPlugin.
|
virtualinherited |
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
Options are typically appended so that a derived 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 Footprint*() functions in all derived PLUGINs.
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 PLUGIN, which has been avoided to date. |
Reimplemented in EAGLE_PLUGIN.
Definition at line 147 of file plugin.cpp.
References _.
Referenced by EAGLE_PLUGIN::FootprintLibOptions().
|
overridevirtual |
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aFootprintName | is the name of the footprint 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. |
aKeepUUID | = true to keep initial items UUID, false to set new UUID normally true if loaded in the footprint editor, false if loaded in the board editor. Make sense only in kicad_plugin |
IO_ERROR | if the library cannot be found or read. No exception is thrown in the case where aFootprintName cannot be found. |
Reimplemented from PLUGIN.
Definition at line 932 of file gpcb_plugin.cpp.
References copy, FOOTPRINT::Duplicate(), and getFootprint().
|
virtualinherited |
Write aFootprint to an existing library located at aLibraryPath.
If a footprint by the same name already exists, it is replaced.
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
aFootprint | is what to store in the library. The caller continues to own the footprint after this call. |
aProperties | is an associative array that can be used to tell the saver how to save the footprint, 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 PCB_PLUGIN.
Definition at line 108 of file plugin.cpp.
References not_implemented().
|
overridevirtual |
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
Reimplemented from PLUGIN.
Definition at line 924 of file gpcb_plugin.cpp.
References getFootprint().
|
inlineoverridevirtual |
Returns the file extension for the PLUGIN.
Implements PLUGIN.
Definition at line 54 of file gpcb_plugin.h.
|
private |
Definition at line 902 of file gpcb_plugin.cpp.
References GPCB_FPL_CACHE::GetFootprints(), init(), m_cache, TO_UTF8, and validateCache().
Referenced by FootprintLoad(), and GetEnumeratedFootprint().
|
virtualinherited |
Return a container with the cached library footprints generated in the last call to Load.
This function is intended to be used ONLY by the non-KiCad board importers for the purpose of obtaining the footprint library of the design and creating a project-specific library.
Reimplemented in EAGLE_PLUGIN, and CADSTAR_PCB_ARCHIVE_PLUGIN.
Definition at line 54 of file plugin.cpp.
References not_implemented().
Referenced by PCB_EDIT_FRAME::OpenProjectFiles().
|
overridevirtual |
Generate a timestamp representing all the files in the library (including the library directory).
Timestamps should not be considered ordered, they either match or they don't.
Implements PLUGIN.
Definition at line 1047 of file gpcb_plugin.cpp.
References GPCB_FPL_CACHE::GetTimestamp().
|
private |
Definition at line 844 of file gpcb_plugin.cpp.
References m_props.
Referenced by FootprintDelete(), FootprintEnumerate(), getFootprint(), GPCB_PLUGIN(), and IsFootprintLibWritable().
|
overridevirtual |
Return true if the library at aLibraryPath is writable.
The system libraries are typically read only because of where they are installed..
aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
IO_ERROR | if no library at aLibraryPath exists. |
Reimplemented from PLUGIN.
Definition at line 1053 of file gpcb_plugin.cpp.
References init(), GPCB_FPL_CACHE::IsWritable(), m_cache, and validateCache().
|
virtualinherited |
Load information from some input file format that this PLUGIN implementation knows about into either a new BOARD or an existing one.
This may be used to load an entire new BOARD, 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. |
aAppendToMe | is an existing BOARD 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. |
aProject | is the optional PROJECT object primarily used by third party importers. |
aProgressReporter | an optional progress reporter |
aLineCount | a line count (necessary if a progress reporter is supplied) |
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 PCB_PLUGIN, EAGLE_PLUGIN, LEGACY_PLUGIN, CLIPBOARD_IO, ALTIUM_DESIGNER_PLUGIN, PCAD_PLUGIN, ALTIUM_CIRCUIT_MAKER_PLUGIN, ALTIUM_CIRCUIT_STUDIO_PLUGIN, CADSTAR_PCB_ARCHIVE_PLUGIN, and FABMASTER_PLUGIN.
Definition at line 46 of file plugin.cpp.
References not_implemented().
Referenced by PCB_CONTROL::AppendBoard(), IO_MGR::Load(), and PCB_EDIT_FRAME::OpenProjectFiles().
|
inlineoverridevirtual |
Return a brief hard coded name for this PLUGIN.
Implements PLUGIN.
Definition at line 49 of file gpcb_plugin.h.
|
virtualinherited |
If possible, prefetches the specified library (e.g.
performing downloads). Does not parse. Threadsafe.
This is a no-op for libraries that cannot be prefetched. Plugins that cannot prefetch need not override this; a default no-op is provided.
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 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 there is an error prefetching the library. |
Definition at line 75 of file plugin.cpp.
|
virtualinherited |
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be used to write a portion of aBoard to a special kind of export file.
aFileName | is the name of a file to save to on disk. |
aBoard | is the class BOARD in memory document tree from which to extract information when writing to aFileName. The caller continues to own the BOARD, and the plugin should refrain from modifying the BOARD if possible. |
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. |
IO_ERROR | if there is a problem saving or exporting. |
Reimplemented in PCB_PLUGIN, and CLIPBOARD_IO.
Definition at line 60 of file plugin.cpp.
References not_implemented().
Referenced by IO_MGR::Save().
|
private |
Definition at line 850 of file gpcb_plugin.cpp.
References GPCB_FPL_CACHE, GPCB_FPL_CACHE::IsModified(), GPCB_FPL_CACHE::Load(), and m_cache.
Referenced by FootprintDelete(), FootprintEnumerate(), getFootprint(), and IsFootprintLibWritable().
|
friend |
Definition at line 97 of file gpcb_plugin.h.
Referenced by validateCache().
|
protected |
Footprint library cache.
Definition at line 102 of file gpcb_plugin.h.
Referenced by FootprintDelete(), FootprintEnumerate(), FootprintLibDelete(), getFootprint(), IsFootprintLibWritable(), validateCache(), and ~GPCB_PLUGIN().
|
protected |
Definition at line 103 of file gpcb_plugin.h.
|
protected |
for throwing exceptions
Definition at line 100 of file gpcb_plugin.h.
|
protected |
for saves only, name is in m_reader for loads
Definition at line 105 of file gpcb_plugin.h.
|
protected |
passed via Save() or Load(), no ownership, may be NULL.
Definition at line 101 of file gpcb_plugin.h.
Referenced by init().
|
protected |