KiCad PCB EDA Suite
SCH_PLUGIN Class Referenceabstract

Class SCH_PLUGIN is a base class that SCHEMATIC loading and saving plugins should derive from. More...

#include <sch_io_mgr.h>

Inheritance diagram for SCH_PLUGIN:
SCH_LEGACY_PLUGIN

Classes

class  SCH_PLUGIN_RELEASER
 Class SCH_PLUGIN_RELEASER. More...
 

Public Member Functions

virtual const wxString GetName () const =0
 Function GetName returns a brief hard coded name for this SCH_PLUGIN. More...
 
virtual const wxString GetFileExtension () const =0
 Function GetFileExtension returns the file extension for the SCH_PLUGIN. More...
 
virtual int GetModifyHash () const =0
 Function GetModifyHash. More...
 
virtual void SaveLibrary (const wxString &aFileName, const PROPERTIES *aProperties=NULL)
 
virtual SCH_SHEETLoad (const wxString &aFileName, KIWAY *aKiway, SCH_SHEET *aAppendToMe=NULL, const PROPERTIES *aProperties=NULL)
 Function Load. More...
 
virtual void Save (const wxString &aFileName, SCH_SCREEN *aSchematic, KIWAY *aKiway, const PROPERTIES *aProperties=NULL)
 Function Save. More...
 
virtual size_t GetSymbolLibCount (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 
virtual void EnumerateSymbolLib (wxArrayString &aAliasNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function EnumerateSymbolLib. More...
 
virtual void EnumerateSymbolLib (std::vector< LIB_ALIAS * > &aAliasList, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function EnumerateSymbolLib. More...
 
virtual LIB_ALIASLoadSymbol (const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL)
 Function LoadSymbol. More...
 
virtual void SaveSymbol (const wxString &aLibraryPath, const LIB_PART *aSymbol, const PROPERTIES *aProperties=NULL)
 Function SaveSymbol. More...
 
virtual void DeleteAlias (const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL)
 Function DeleteAlias. More...
 
virtual void DeleteSymbol (const wxString &aLibraryPath, const wxString &aAliasName, const PROPERTIES *aProperties=NULL)
 Function DeleteSymbol. More...
 
virtual void CreateSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function CreateSymbolLib. More...
 
virtual bool DeleteSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function DeleteSymbolLib. More...
 
virtual bool IsSymbolLibWritable (const wxString &aLibraryPath)
 Function IsSymbolLibWritable returns true if the library at aLibraryPath is writable. More...
 
virtual void SymbolLibOptions (PROPERTIES *aListToAppendTo) const
 Function SymbolLibOptions. More...
 
virtual ~SCH_PLUGIN ()
 

Detailed Description

Class SCH_PLUGIN is a base class that SCHEMATIC 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 187 of file sch_io_mgr.h.

Constructor & Destructor Documentation

virtual SCH_PLUGIN::~SCH_PLUGIN ( )
inlinevirtual

Definition at line 515 of file sch_io_mgr.h.

515 { }

Member Function Documentation

void SCH_PLUGIN::CreateSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtual

Function CreateSymbolLib.

creates 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.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis 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.
Exceptions
IO_ERRORif there is a problem finding the library, or creating it.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 134 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::CreateSymbolLib().

135 {
136  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
137  not_implemented( this, __FUNCTION__ );
138 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::DeleteAlias ( const wxString &  aLibraryPath,
const wxString &  aAliasName,
const PROPERTIES aProperties = NULL 
)
virtual

Function DeleteAlias.

deletes aAliasName from the library at aLibraryPath.

If aAliasName refers the the root LIB_PART object, the part is renamed to the next or previous LIB_ALIAS in the LIB_PART if one exists. If the LIB_ALIAS is the last alias referring to the root LIB_PART, the LIB_PART is also removed from the library.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aAliasNameis the name of a LIB_ALIAS to delete from the specified library.
aPropertiesis 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.
Exceptions
IO_ERRORif there is a problem finding the alias or the library or deleting it.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 118 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::DeleteAlias().

120 {
121  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
122  not_implemented( this, __FUNCTION__ );
123 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::DeleteSymbol ( const wxString &  aLibraryPath,
const wxString &  aAliasName,
const PROPERTIES aProperties = NULL 
)
virtual

Function DeleteSymbol.

deletes the entire LIB_PART associated with aAliasName from the library aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aAliasNameis the name of a LIB_ALIAS associated with it's root LIB_PART object to delete from the specified library.
aPropertiesis 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.
Exceptions
IO_ERRORif there is a problem finding the alias or the library or deleting it.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 126 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::DeleteSymbol().

128 {
129  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
130  not_implemented( this, __FUNCTION__ );
131 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
bool SCH_PLUGIN::DeleteSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtual

Function DeleteSymbolLib.

deletes 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.

Parameters
aLibraryPathis a locator for the "library", usually a directory or file which will contain symbols.
aPropertiesis 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.
Returns
bool - true if library deleted, false if library did not exist.
Exceptions
IO_ERRORif there is a problem deleting an existing library.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 141 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::DeleteSymbolLib().

142 {
143  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
144  not_implemented( this, __FUNCTION__ );
145  return false;
146 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::EnumerateSymbolLib ( wxArrayString &  aAliasNameList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtual

Function EnumerateSymbolLib.

returns a list of LIB_PART alias names contained within the library aLibraryPath.

Parameters
aAliasNameListis an array to populate with the LIB_ALIAS names associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects.
aPropertiesis 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.
Exceptions
IO_ERRORif the library cannot be found, the part library cannot be loaded.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 83 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::EnumerateSymbolLib().

86 {
87  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
88  not_implemented( this, __FUNCTION__ );
89 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::EnumerateSymbolLib ( std::vector< LIB_ALIAS * > &  aAliasList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtual

Function EnumerateSymbolLib.

returns a list of LIB_PART aliases contained within the library aLibraryPath.

Parameters
aAliasListis an array to populate with the LIB_ALIAS pointers associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects.
aPropertiesis 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.
Exceptions
IO_ERRORif the library cannot be found, the part library cannot be loaded.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 92 of file sch_plugin.cpp.

References not_implemented().

95 {
96  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
97  not_implemented( this, __FUNCTION__ );
98 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
virtual const wxString SCH_PLUGIN::GetFileExtension ( ) const
pure virtual

Function GetFileExtension returns the file extension for the SCH_PLUGIN.

Implemented in SCH_LEGACY_PLUGIN.

Referenced by SCH_IO_MGR::GetFileExtension().

virtual int SCH_PLUGIN::GetModifyHash ( ) const
pure virtual

Function GetModifyHash.

returns the modification hash from the library cache.

Note
This is temporary until the new s-expr file format is implement. The new file format will embed symbols instead of referencing them from the library. This function can be removed when the new file format is implemented.
Returns
the modification hash of the library cache.

Implemented in SCH_LEGACY_PLUGIN.

virtual const wxString SCH_PLUGIN::GetName ( ) const
pure virtual

Function GetName returns a brief hard coded name for this SCH_PLUGIN.

Implemented in SCH_LEGACY_PLUGIN.

Referenced by not_implemented().

size_t SCH_PLUGIN::GetSymbolLibCount ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtual

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 74 of file sch_plugin.cpp.

References not_implemented().

76 {
77  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
78  not_implemented( this, __FUNCTION__ );
79  return 0;
80 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
bool SCH_PLUGIN::IsSymbolLibWritable ( const wxString &  aLibraryPath)
virtual

Function IsSymbolLibWritable returns true if the library at aLibraryPath is writable.

(Often system libraries are read only because of where they are installed.)

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
Exceptions
IO_ERRORif no library at aLibraryPath exists.

Definition at line 149 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::IsSymbolLibWritable().

150 {
151  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
152  not_implemented( this, __FUNCTION__ );
153  return false;
154 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
SCH_SHEET * SCH_PLUGIN::Load ( const wxString &  aFileName,
KIWAY aKiway,
SCH_SHEET aAppendToMe = NULL,
const PROPERTIES aProperties = NULL 
)
virtual

Function Load.

loads information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCHEMATIC or an existing one. This may be used to load an entire new SCHEMATIC, or to augment an existing one if aAppendToMe is not NULL.

Parameters
aFileNameis the name of the file to use as input and may be foreign in nature or native in nature.
aAppendToMeis an existing SCHEMATIC to append to, but if NULL then this means "do not append, rather load anew".
aPropertiesis 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.
Returns
SCHEMATIC* - the successfully loaded schematic, or the same one as aAppendToMe if aAppendToMe was not NULL, and the caller owns it.
Exceptions
IO_ERRORif 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.

Definition at line 58 of file sch_plugin.cpp.

References not_implemented().

Referenced by SCH_IO_MGR::Load(), and SCH_EDIT_FRAME::OpenProjectFiles().

60 {
61  not_implemented( this, __FUNCTION__ );
62  return NULL;
63 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
LIB_ALIAS * SCH_PLUGIN::LoadSymbol ( const wxString &  aLibraryPath,
const wxString &  aAliasName,
const PROPERTIES aProperties = NULL 
)
virtual

Function LoadSymbol.

loads a LIB_ALIAS object having aAliasName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about. The LIB_PART should be accessed indirectly using the LIB_ALIAS it is associated with.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aAliasNameis the alias name of the LIB_PART to load.
aPropertiesis 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.
Returns
LIB_ALIAS* - if found caller shares it, else NULL if not found.
Exceptions
IO_ERRORif the library cannot be found or read. No exception is thrown in the case where aAliasName cannot be found.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 101 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::LoadSymbol(), and SYMBOL_LIB_TABLE::SaveSymbol().

103 {
104  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
105  not_implemented( this, __FUNCTION__ );
106  return NULL;
107 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::Save ( const wxString &  aFileName,
SCH_SCREEN aSchematic,
KIWAY aKiway,
const PROPERTIES aProperties = NULL 
)
virtual

Function Save.

will 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.

Parameters
aFileNameis the name of a file to save to on disk.
aSchematicis the class SCHEMATIC 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.
aPropertiesis 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.
Exceptions
IO_ERRORif there is a problem saving or exporting.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 66 of file sch_plugin.cpp.

References not_implemented().

Referenced by SCH_IO_MGR::Save().

68 {
69  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
70  not_implemented( this, __FUNCTION__ );
71 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::SaveLibrary ( const wxString &  aFileName,
const PROPERTIES aProperties = NULL 
)
virtual

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 52 of file sch_plugin.cpp.

References not_implemented().

53 {
54  not_implemented( this, __FUNCTION__ );
55 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::SaveSymbol ( const wxString &  aLibraryPath,
const LIB_PART aSymbol,
const PROPERTIES aProperties = NULL 
)
virtual

Function SaveSymbol.

will 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 becaue libraries cannot have duplicate alias names. It is the responsibility of the caller to check the library for conflicts before saving.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aSymbolis what to store in the library. The library is refreshed and the caller must update any LIB_PART pointers that may have changed.
aPropertiesis 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.
Exceptions
IO_ERRORif there is a problem saving.

Reimplemented in SCH_LEGACY_PLUGIN.

Definition at line 110 of file sch_plugin.cpp.

References not_implemented().

Referenced by SYMBOL_LIB_TABLE::SaveSymbol().

112 {
113  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
114  not_implemented( this, __FUNCTION__ );
115 }
static void not_implemented(SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: sch_plugin.cpp:36
void SCH_PLUGIN::SymbolLibOptions ( PROPERTIES aListToAppendTo) const
virtual

Function SymbolLibOptions.

appends 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.

Parameters
aListToAppendToholds a tuple of
option
This eventually is what shows up into the fp-lib-table "options" field, possibly combined with others.
internationalized description
The internationalized description is displayed in DIALOG_FP_SCH_PLUGIN_OPTIONS. It may be multi-line and be quite explanatory of the option.

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 157 of file sch_plugin.cpp.

158 {
159  // disable all these in another couple of months, after everyone has seen them:
160 #if 1
161  (*aListToAppendTo)["debug_level"] = UTF8( _(
162  "Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
163  ) );
164 
165  (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
166  "Regular expression <b>symbol name</b> filter."
167  ) );
168 
169  (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
170  "Enable transaction logging. The mere presence of this option turns on the "
171  "logging, no need to set a Value."
172  ) );
173 
174  (*aListToAppendTo)["username"] = UTF8( _(
175  "User name for <b>login</b> to some special library server."
176  ));
177 
178  (*aListToAppendTo)["password"] = UTF8( _(
179  "Password for <b>login</b> to some special library server."
180  ) );
181 #endif
182 
183 #if 1
184  // Suitable for a C++ to python SCH_PLUGIN::Footprint*() adapter, move it to the adapter
185  // if and when implemented.
186  (*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
187  "Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
188  ) );
189 #endif
190 }
Class UTF8 is an 8 bit std::string that is assuredly encoded in UTF8, and supplies special conversion...
Definition: utf8.h:53

The documentation for this class was generated from the following files: