KiCad PCB EDA Suite
PCAD_PLUGIN Class Reference

#include <pcad_plugin.h>

Inheritance diagram for PCAD_PLUGIN:
PLUGIN

Public Member Functions

const wxString PluginName () const override
 Function PluginName returns a brief hard coded name for this PLUGIN. More...
 
BOARDLoad (const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL) override
 Function Load loads information from some input file format that this PLUGIN implementation knows about, into either a new BOARD or an existing one. More...
 
const wxString GetFileExtension () const override
 Function GetFileExtension returns the file extension for the PLUGIN. More...
 
long long GetLibraryTimestamp (const wxString &aLibraryPath) const override
 Generate a timestamp representing all the files in the library (including the library directory). More...
 
 PCAD_PLUGIN ()
 
 ~PCAD_PLUGIN ()
 
virtual void Save (const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL)
 Function Save will 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 FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Return a list of footprint names contained within the library at aLibraryPath. More...
 
virtual void PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function PrefetchLib If possible, prefetches the specified library (e.g. More...
 
virtual MODULEFootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
 Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about. More...
 
virtual const MODULEGetEnumeratedFootprint (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
 Function GetEnumeratedFootprint a version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management. More...
 
virtual void FootprintSave (const wxString &aLibraryPath, const MODULE *aFootprint, const PROPERTIES *aProperties=NULL)
 Function FootprintSave will write aModule to an existing library located at aLibraryPath. More...
 
virtual void FootprintDelete (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
 Function FootprintDelete deletes aFootprintName from the library at aLibraryPath. More...
 
virtual void FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function FootprintLibCreate creates a new empty footprint library at aLibraryPath empty. More...
 
virtual bool FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function FootprintLibDelete deletes 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...
 
virtual bool IsFootprintLibWritable (const wxString &aLibraryPath)
 Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable. More...
 
virtual void FootprintLibOptions (PROPERTIES *aListToAppendTo) const
 Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 

Private Attributes

const PROPERTIESm_props
 
BOARDm_board
 

Detailed Description

Definition at line 36 of file pcad_plugin.h.

Constructor & Destructor Documentation

PCAD_PLUGIN::PCAD_PLUGIN ( )

Definition at line 46 of file pcad_plugin.cpp.

Referenced by GetLibraryTimestamp().

47 {
48  m_board = NULL;
49  m_props = NULL;
50 }
BOARD * m_board
Definition: pcad_plugin.h:63
const PROPERTIES * m_props
Definition: pcad_plugin.h:62
PCAD_PLUGIN::~PCAD_PLUGIN ( )

Definition at line 53 of file pcad_plugin.cpp.

Referenced by GetLibraryTimestamp().

54 {
55 }

Member Function Documentation

void PLUGIN::FootprintDelete ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintDelete deletes aFootprintName from the library at aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintNameis the name of a footprint 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 footprint or the library, or deleting it.

Reimplemented in GITHUB_PLUGIN, PCB_IO, and GPCB_PLUGIN.

Definition at line 101 of file plugin.cpp.

References not_implemented().

Referenced by FP_LIB_TABLE::FootprintDelete().

103 {
104  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
105  not_implemented( this, __FUNCTION__ );
106 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
void PLUGIN::FootprintEnumerate ( wxArrayString &  aFootprintNames,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Return a list of footprint names contained within the library at aLibraryPath.

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 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.
aFootprintNamesis the array of available footprint names inside a library.
Exceptions
IO_ERRORif the library cannot be found, or footprint cannot be loaded.

Reimplemented in GITHUB_PLUGIN, EAGLE_PLUGIN, PCB_IO, LEGACY_PLUGIN, and GPCB_PLUGIN.

Definition at line 60 of file plugin.cpp.

References not_implemented().

Referenced by FP_LIB_TABLE::FootprintEnumerate(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().

62 {
63  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
64  not_implemented( this, __FUNCTION__ );
65 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
void PLUGIN::FootprintLibCreate ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtualinherited

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

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 GITHUB_PLUGIN, and PCB_IO.

Definition at line 109 of file plugin.cpp.

References not_implemented().

Referenced by PCB_BASE_EDIT_FRAME::CreateNewLibrary(), and FP_LIB_TABLE::FootprintLibCreate().

110 {
111  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
112  not_implemented( this, __FUNCTION__ );
113 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
bool PLUGIN::FootprintLibDelete ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtualinherited

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

Parameters
aLibraryPathis a locator for the "library", usually a directory or file which will contain footprints.
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 GITHUB_PLUGIN, PCB_IO, LEGACY_PLUGIN, and GPCB_PLUGIN.

Definition at line 116 of file plugin.cpp.

References not_implemented().

Referenced by PCB_BASE_EDIT_FRAME::CreateNewLibrary(), and FP_LIB_TABLE::FootprintLibDelete().

117 {
118  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
119  not_implemented( this, __FUNCTION__ );
120  return false;
121 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
void PLUGIN::FootprintLibOptions ( PROPERTIES aListToAppendTo) const
virtualinherited

Function FootprintLibOptions appends 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.) 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_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 PLUGIN, which has been avoided to date.

Reimplemented in GITHUB_PLUGIN, and EAGLE_PLUGIN.

Definition at line 132 of file plugin.cpp.

Referenced by DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), EAGLE_PLUGIN::FootprintLibOptions(), and GITHUB_PLUGIN::FootprintLibOptions().

133 {
134  // disable all these in another couple of months, after everyone has seen them:
135 #if 1
136  (*aListToAppendTo)["debug_level"] = UTF8( _(
137  "Enable <b>debug</b> logging for Footprint*() functions in this PLUGIN."
138  ));
139 
140  (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
141  "Regular expression <b>footprint name</b> filter."
142  ));
143 
144  (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
145  "Enable transaction logging. The mere presence of this option turns on the "
146  "logging, no need to set a Value."
147  ));
148 
149  (*aListToAppendTo)["username"] = UTF8( _(
150  "User name for <b>login</b> to some special library server."
151  ));
152 
153  (*aListToAppendTo)["password"] = UTF8( _(
154  "Password for <b>login</b> to some special library server."
155  ));
156 #endif
157 
158 #if 1
159  // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
160  // if and when implemented.
161  (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _(
162  "Enter the python module which implements the PLUGIN::Footprint*() functions."
163  ));
164 #endif
165 }
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
MODULE * PLUGIN::FootprintLoad ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a library format that this PLUGIN knows about.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintNameis the name of the footprint 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
MODULE* - if found caller owns it, else NULL if not found.
Exceptions
IO_ERRORif the library cannot be found or read. No exception is thrown in the case where aFootprintName cannot be found.

Reimplemented in GITHUB_PLUGIN, PCB_IO, EAGLE_PLUGIN, LEGACY_PLUGIN, and GPCB_PLUGIN.

Definition at line 84 of file plugin.cpp.

References not_implemented().

Referenced by FP_LIB_TABLE::FootprintLoad(), FP_LIB_TABLE::FootprintSave(), PLUGIN::GetEnumeratedFootprint(), and parse_module_with_plugin().

86 {
87  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
88  not_implemented( this, __FUNCTION__ );
89  return NULL;
90 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
void PLUGIN::FootprintSave ( const wxString &  aLibraryPath,
const MODULE aFootprint,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function FootprintSave will write aModule to an existing library located at aLibraryPath.

If a footprint by the same name already exists, it is replaced.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aFootprintis what to store in the library. The caller continues to own the footprint after this call.
aPropertiesis 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.
Exceptions
IO_ERRORif there is a problem saving.

Reimplemented in GITHUB_PLUGIN, and PCB_IO.

Definition at line 93 of file plugin.cpp.

References not_implemented().

Referenced by PCB_EDIT_FRAME::ArchiveModulesOnBoard(), FP_LIB_TABLE::FootprintSave(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().

95 {
96  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
97  not_implemented( this, __FUNCTION__ );
98 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
const MODULE * PLUGIN::GetEnumeratedFootprint ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function GetEnumeratedFootprint a version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.

Reimplemented in PCB_IO, and GPCB_PLUGIN.

Definition at line 75 of file plugin.cpp.

References PLUGIN::FootprintLoad().

Referenced by FP_LIB_TABLE::GetEnumeratedFootprint(), and FOOTPRINT_EDIT_FRAME::SaveLibraryAs().

78 {
79  // default implementation
80  return FootprintLoad( aLibraryPath, aFootprintName, aProperties );
81 }
virtual MODULE * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL)
Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a lib...
Definition: plugin.cpp:84
const wxString PCAD_PLUGIN::GetFileExtension ( ) const
overridevirtual

Function GetFileExtension returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 64 of file pcad_plugin.cpp.

65 {
66  return wxT( "pcb" );
67 }
long long PCAD_PLUGIN::GetLibraryTimestamp ( const wxString &  aLibraryPath) const
inlineoverridevirtual

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 50 of file pcad_plugin.h.

References PCAD_PLUGIN(), and ~PCAD_PLUGIN().

51  {
52  // No support for libraries....
53  return 0;
54  }
bool PLUGIN::IsFootprintLibWritable ( const wxString &  aLibraryPath)
virtualinherited

Function IsFootprintLibWritable returns true iff 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 footprints.
Exceptions
IO_ERRORif no library at aLibraryPath exists.

Reimplemented in GITHUB_PLUGIN, PCB_IO, EAGLE_PLUGIN, LEGACY_PLUGIN, and GPCB_PLUGIN.

Definition at line 124 of file plugin.cpp.

References not_implemented().

Referenced by PCB_BASE_EDIT_FRAME::CreateNewLibrary(), and FP_LIB_TABLE::IsFootprintLibWritable().

125 {
126  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
127  not_implemented( this, __FUNCTION__ );
128  return false;
129 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38
BOARD * PCAD_PLUGIN::Load ( const wxString &  aFileName,
BOARD aAppendToMe,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function Load loads 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.

Parameters
aFileNameis the name of the file to use as input and may be foreign in nature or native in nature.
aAppendToMeis an existing BOARD 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
BOARD* - the successfully loaded board, or the same one as aAppendToMe if aAppendToMe was not NULL, and 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 from PLUGIN.

Definition at line 70 of file pcad_plugin.cpp.

References PCAD2KICAD::PCB::AddToBoard(), PCAD2KICAD::LoadInputFile(), and PCAD2KICAD::PCB::ParseBoard().

71 {
72  wxXmlDocument xmlDoc;
73 
74  m_props = aProperties;
75 
76  m_board = aAppendToMe ? aAppendToMe : new BOARD();
77 
78  // Give the filename to the board if it's new
79  if( !aAppendToMe )
80  m_board->SetFileName( aFileName );
81 
82  PCB pcb( m_board );
83 
84  LOCALE_IO toggle; // toggles on, then off, the C locale.
85 
86  LoadInputFile( aFileName, &xmlDoc );
87  pcb.ParseBoard( NULL, &xmlDoc, wxT( "PCB" ) );
88  pcb.AddToBoard();
89 
90  return m_board;
91 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown...
Definition: common.h:179
BOARD * m_board
Definition: pcad_plugin.h:63
void LoadInputFile(const wxString &aFileName, wxXmlDocument *aXmlDoc)
void SetFileName(const wxString &aFileName)
Definition: class_board.h:235
const PROPERTIES * m_props
Definition: pcad_plugin.h:62
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
const wxString PCAD_PLUGIN::PluginName ( ) const
overridevirtual

Function PluginName returns a brief hard coded name for this PLUGIN.

Implements PLUGIN.

Definition at line 58 of file pcad_plugin.cpp.

59 {
60  return wxT( "P-Cad" );
61 }
void PLUGIN::PrefetchLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
virtualinherited

Function PrefetchLib 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.

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 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 there is an error prefetching the library.

Reimplemented in GITHUB_PLUGIN.

Definition at line 68 of file plugin.cpp.

Referenced by FP_LIB_TABLE::PrefetchLib().

69 {
70  (void) aLibraryPath;
71  (void) aProperties;
72 }
void PLUGIN::Save ( const wxString &  aFileName,
BOARD aBoard,
const PROPERTIES aProperties = NULL 
)
virtualinherited

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

Parameters
aFileNameis the name of a file to save to on disk.
aBoardis 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.
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 PCB_IO, and CLIPBOARD_IO.

Definition at line 53 of file plugin.cpp.

References not_implemented().

Referenced by IO_MGR::Save(), PCB_EDIT_FRAME::SavePcbCopy(), and PCB_EDIT_FRAME::SavePcbFile().

54 {
55  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
56  not_implemented( this, __FUNCTION__ );
57 }
static void not_implemented(PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented...
Definition: plugin.cpp:38

Member Data Documentation

BOARD* PCAD_PLUGIN::m_board
private

Definition at line 63 of file pcad_plugin.h.

const PROPERTIES* PCAD_PLUGIN::m_props
private

Definition at line 62 of file pcad_plugin.h.


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