KiCad PCB EDA Suite
GPCB_PLUGIN Class Reference

Class GPCB_PLUGIN is a PLUGIN derivation for saving and loading Geda PCB files. More...

#include <gpcb_plugin.h>

Inheritance diagram for GPCB_PLUGIN:
PLUGIN

Public Member Functions

const wxString PluginName () const override
 Function PluginName returns a brief hard coded name for this PLUGIN. More...
 
const wxString GetFileExtension () const override
 Function GetFileExtension returns the file extension for the PLUGIN. More...
 
wxArrayString FootprintEnumerate (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 Function FootprintEnumerate returns a list of footprint names contained within the library at aLibraryPath. More...
 
MODULEFootprintLoad (const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
 Function FootprintLoad loads 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=NULL) override
 Function FootprintDelete deletes aFootprintName from the library at aLibraryPath. More...
 
bool FootprintLibDelete (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
 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...
 
bool IsFootprintLibWritable (const wxString &aLibraryPath) override
 Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable. More...
 
 GPCB_PLUGIN ()
 
 GPCB_PLUGIN (int aControlFlags)
 
 ~GPCB_PLUGIN ()
 
virtual BOARDLoad (const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL)
 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...
 
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 PrefetchLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function PrefetchLib If possible, prefetches the specified library (e.g. 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 FootprintLibCreate (const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL)
 Function FootprintLibCreate creates a new empty footprint library at aLibraryPath empty. More...
 
virtual void FootprintLibOptions (PROPERTIES *aListToAppendTo) const
 Function FootprintLibOptions appends supported PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 

Protected Attributes

wxString m_error
 for throwing exceptions More...
 
const PROPERTIESm_props
 passed via Save() or Load(), no ownership, may be NULL. More...
 
GPCB_FPL_CACHEm_cache
 Footprint library cache. More...
 
int m_ctl
 
LINE_READERm_reader
 no ownership here. More...
 
wxString m_filename
 for saves only, name is in m_reader for loads More...
 

Private Member Functions

void cacheLib (const wxString &aLibraryPath, const wxString &aFootprintName=wxEmptyString)
 we only cache one footprint library for now, this determines which one. More...
 
void init (const PROPERTIES *aProperties)
 

Friends

class GPCB_FPL_CACHE
 

Detailed Description

Class GPCB_PLUGIN is a PLUGIN derivation for saving and loading Geda PCB files.

Note
This class is not thread safe, but it is re-entrant multiple times in sequence.
Currently only reading GPCB footprint files is implemented.

Definition at line 47 of file gpcb_plugin.h.

Constructor & Destructor Documentation

GPCB_PLUGIN::GPCB_PLUGIN ( )

Definition at line 935 of file gpcb_plugin.cpp.

References init(), and m_reader.

935  :
936  m_cache( 0 ),
937  m_ctl( 0 )
938 {
939  m_reader = NULL;
940  init( 0 );
941 }
void init(const PROPERTIES *aProperties)
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
LINE_READER * m_reader
no ownership here.
Definition: gpcb_plugin.h:92
GPCB_PLUGIN::GPCB_PLUGIN ( int  aControlFlags)

Definition at line 944 of file gpcb_plugin.cpp.

References init(), and m_reader.

944  :
945  m_cache( 0 ),
946  m_ctl( aControlFlags )
947 {
948  m_reader = NULL;
949  init( 0 );
950 }
void init(const PROPERTIES *aProperties)
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
LINE_READER * m_reader
no ownership here.
Definition: gpcb_plugin.h:92
GPCB_PLUGIN::~GPCB_PLUGIN ( )

Definition at line 953 of file gpcb_plugin.cpp.

References m_cache.

954 {
955  delete m_cache;
956 }
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90

Member Function Documentation

void GPCB_PLUGIN::cacheLib ( const wxString &  aLibraryPath,
const wxString &  aFootprintName = wxEmptyString 
)
private

we only cache one footprint library for now, this determines which one.

Definition at line 965 of file gpcb_plugin.cpp.

References GPCB_FPL_CACHE, GPCB_FPL_CACHE::IsModified(), GPCB_FPL_CACHE::Load(), and m_cache.

Referenced by FootprintDelete(), FootprintEnumerate(), FootprintLoad(), and IsFootprintLibWritable().

966 {
967  if( !m_cache || m_cache->IsModified( aLibraryPath, aFootprintName ) )
968  {
969  // a spectacular episode in memory management:
970  delete m_cache;
971  m_cache = new GPCB_FPL_CACHE( this, aLibraryPath );
972  m_cache->Load();
973  }
974 }
bool IsModified(const wxString &aLibPath, const wxString &aFootprintName=wxEmptyString) const
Function IsModified check if the footprint cache has been modified relative to aLibPath and aFootprin...
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
void Load()
Save not implemented for the Geda PCB footprint library format.
friend class GPCB_FPL_CACHE
Definition: gpcb_plugin.h:49
void GPCB_PLUGIN::FootprintDelete ( const wxString &  aLibraryPath,
const wxString &  aFootprintName,
const PROPERTIES aProperties = NULL 
)
overridevirtual

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 from PLUGIN.

Definition at line 1044 of file gpcb_plugin.cpp.

References cacheLib(), Format(), init(), GPCB_FPL_CACHE::IsWritable(), m_cache, GPCB_FPL_CACHE::Remove(), and THROW_IO_ERROR.

1046 {
1047  LOCALE_IO toggle; // toggles on, then off, the C locale.
1048 
1049  init( aProperties );
1050 
1051  cacheLib( aLibraryPath );
1052 
1053  if( !m_cache->IsWritable() )
1054  {
1055  THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ),
1056  aLibraryPath.GetData() ) );
1057  }
1058 
1059  m_cache->Remove( aFootprintName );
1060 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
void cacheLib(const wxString &aLibraryPath, const wxString &aFootprintName=wxEmptyString)
we only cache one footprint library for now, this determines which one.
void Remove(const wxString &aFootprintName)
void init(const PROPERTIES *aProperties)
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
#define THROW_IO_ERROR(x)
Definition: utf8.cpp:60
bool IsWritable() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxArrayString GPCB_PLUGIN::FootprintEnumerate ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

Function FootprintEnumerate returns 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.
Returns
wxArrayString - is the array of available footprint names inside a library
Exceptions
IO_ERRORif the library cannot be found, or footprint cannot be loaded.

Reimplemented from PLUGIN.

Definition at line 977 of file gpcb_plugin.cpp.

References cacheLib(), Format(), FROM_UTF8(), GedaPcbFootprintLibFileExtension, GetChars(), GPCB_FPL_CACHE::GetModules(), init(), m_cache, and THROW_IO_ERROR.

979 {
980  LOCALE_IO toggle; // toggles on, then off, the C locale.
981  wxArrayString ret;
982  wxDir dir( aLibraryPath );
983 
984  if( !dir.IsOpened() )
985  {
986  THROW_IO_ERROR( wxString::Format( _( "footprint library path '%s' does not exist" ),
987  GetChars( aLibraryPath ) ) );
988  }
989 
990  init( aProperties );
991 
992 #if 1 // Set to 0 to only read directory contents, not load cache.
993 
994  cacheLib( aLibraryPath );
995 
996  const MODULE_MAP& mods = m_cache->GetModules();
997 
998 
999  for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
1000  {
1001  ret.Add( FROM_UTF8( it->first.c_str() ) );
1002  }
1003 #else
1004  wxString fpFileName;
1005  wxString wildcard = wxT( "*." ) + GedaPcbFootprintLibFileExtension;
1006 
1007  if( dir.GetFirst( &fpFileName, wildcard, wxDIR_FILES ) )
1008  {
1009  do
1010  {
1011  wxFileName fn( aLibraryPath, fpFileName );
1012  ret.Add( fn.GetName() );
1013  } while( dir.GetNext( &fpFileName ) );
1014  }
1015 #endif
1016 
1017  return ret;
1018 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
MODULE_MAP & GetModules()
void cacheLib(const wxString &aLibraryPath, const wxString &aFootprintName=wxEmptyString)
we only cache one footprint library for now, this determines which one.
void init(const PROPERTIES *aProperties)
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
const wxString GedaPcbFootprintLibFileExtension
std::map< std::string, MODULE * > MODULE_MAP
Definition: eagle_plugin.h:36
#define THROW_IO_ERROR(x)
Definition: utf8.cpp:60
MODULE_MAP::const_iterator MODULE_CITER
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
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 99 of file plugin.cpp.

References not_implemented().

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

100 {
101  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
102  not_implemented( this, __FUNCTION__ );
103 }
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 GPCB_PLUGIN::FootprintLibDelete ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = NULL 
)
overridevirtual

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 from PLUGIN.

Definition at line 1063 of file gpcb_plugin.cpp.

References Format(), GPCB_FPL_CACHE::GetPath(), KiCadFootprintFileExtension, m_cache, THROW_IO_ERROR, and traceFootprintLibrary().

1064 {
1065  wxFileName fn;
1066  fn.SetPath( aLibraryPath );
1067 
1068  // Return if there is no library path to delete.
1069  if( !fn.DirExists() )
1070  return false;
1071 
1072  if( !fn.IsDirWritable() )
1073  {
1074  THROW_IO_ERROR( wxString::Format( _( "user does not have permission to delete directory '%s'" ),
1075  aLibraryPath.GetData() ) );
1076  }
1077 
1078  wxDir dir( aLibraryPath );
1079 
1080  if( dir.HasSubDirs() )
1081  {
1082  THROW_IO_ERROR( wxString::Format( _( "library directory '%s' has unexpected sub-directories" ),
1083  aLibraryPath.GetData() ) );
1084  }
1085 
1086  // All the footprint files must be deleted before the directory can be deleted.
1087  if( dir.HasFiles() )
1088  {
1089  unsigned i;
1090  wxFileName tmp;
1091  wxArrayString files;
1092 
1093  wxDir::GetAllFiles( aLibraryPath, &files );
1094 
1095  for( i = 0; i < files.GetCount(); i++ )
1096  {
1097  tmp = files[i];
1098 
1099  if( tmp.GetExt() != KiCadFootprintFileExtension )
1100  {
1101  THROW_IO_ERROR( wxString::Format( _( "unexpected file '%s' was found in library path '%s'" ),
1102  files[i].GetData(), aLibraryPath.GetData() ) );
1103  }
1104  }
1105 
1106  for( i = 0; i < files.GetCount(); i++ )
1107  {
1108  wxRemoveFile( files[i] );
1109  }
1110  }
1111 
1112  wxLogTrace( traceFootprintLibrary, wxT( "Removing footprint library '%s'" ),
1113  aLibraryPath.GetData() );
1114 
1115  // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
1116  // we don't want that. we want bare metal portability with no UI here.
1117  if( !wxRmdir( aLibraryPath ) )
1118  {
1119  THROW_IO_ERROR( wxString::Format( _( "footprint library '%s' cannot be deleted" ),
1120  aLibraryPath.GetData() ) );
1121  }
1122 
1123  // For some reason removing a directory in Windows is not immediately updated. This delay
1124  // prevents an error when attempting to immediately recreate the same directory when over
1125  // writing an existing library.
1126 #ifdef __WINDOWS__
1127  wxMilliSleep( 250L );
1128 #endif
1129 
1130  if( m_cache && m_cache->GetPath() == aLibraryPath )
1131  {
1132  delete m_cache;
1133  m_cache = NULL;
1134  }
1135 
1136  return true;
1137 }
const wxString KiCadFootprintFileExtension
wxString GetPath() const
static const wxString traceFootprintLibrary(wxT("GedaPcbFootprintLib"))
Definition for enabling and disabling footprint library trace output.
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
#define THROW_IO_ERROR(x)
Definition: utf8.cpp:60
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
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 122 of file plugin.cpp.

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

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

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 from PLUGIN.

Definition at line 1021 of file gpcb_plugin.cpp.

References cacheLib(), GPCB_FPL_CACHE::GetModules(), init(), m_cache, and TO_UTF8.

1023 {
1024  LOCALE_IO toggle; // toggles on, then off, the C locale.
1025 
1026  init( aProperties );
1027 
1028  cacheLib( aLibraryPath, aFootprintName );
1029 
1030  const MODULE_MAP& mods = m_cache->GetModules();
1031 
1032  MODULE_CITER it = mods.find( TO_UTF8( aFootprintName ) );
1033 
1034  if( it == mods.end() )
1035  {
1036  return NULL;
1037  }
1038 
1039  // copy constructor to clone the already loaded MODULE
1040  return new MODULE( *it->second->GetModule() );
1041 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
MODULE_MAP & GetModules()
void cacheLib(const wxString &aLibraryPath, const wxString &aFootprintName=wxEmptyString)
we only cache one footprint library for now, this determines which one.
void init(const PROPERTIES *aProperties)
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
std::map< std::string, MODULE * > MODULE_MAP
Definition: eagle_plugin.h:36
MODULE_MAP::const_iterator MODULE_CITER
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 85 of file plugin.cpp.

References not_implemented().

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

86 {
87  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
88  not_implemented( this, __FUNCTION__ );
89 }
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 wxString GPCB_PLUGIN::GetFileExtension ( ) const
inlineoverridevirtual

Function GetFileExtension returns the file extension for the PLUGIN.

Implements PLUGIN.

Definition at line 60 of file gpcb_plugin.h.

61  {
62  return wxT( "fp" );
63  }
void GPCB_PLUGIN::init ( const PROPERTIES aProperties)
private

Definition at line 959 of file gpcb_plugin.cpp.

References m_props.

Referenced by FootprintDelete(), FootprintEnumerate(), FootprintLoad(), GPCB_PLUGIN(), and IsFootprintLibWritable().

960 {
961  m_props = aProperties;
962 }
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: gpcb_plugin.h:89
bool GPCB_PLUGIN::IsFootprintLibWritable ( const wxString &  aLibraryPath)
overridevirtual

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 from PLUGIN.

Definition at line 1140 of file gpcb_plugin.cpp.

References cacheLib(), init(), GPCB_FPL_CACHE::IsWritable(), and m_cache.

1141 {
1142  LOCALE_IO toggle;
1143 
1144  init( NULL );
1145 
1146  cacheLib( aLibraryPath );
1147 
1148  return m_cache->IsWritable();
1149 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
void cacheLib(const wxString &aLibraryPath, const wxString &aFootprintName=wxEmptyString)
we only cache one footprint library for now, this determines which one.
void init(const PROPERTIES *aProperties)
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:90
bool IsWritable() const
BOARD * PLUGIN::Load ( const wxString &  aFileName,
BOARD aAppendToMe,
const PROPERTIES aProperties = NULL 
)
virtualinherited

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 in PCB_IO, EAGLE_PLUGIN, LEGACY_PLUGIN, and PCAD_PLUGIN.

Definition at line 47 of file plugin.cpp.

References not_implemented().

Referenced by PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::AppendBoardFile(), IO_MGR::Load(), and PCB_EDIT_FRAME::OpenProjectFiles().

48 {
49  not_implemented( this, __FUNCTION__ );
50  return NULL;
51 }
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 wxString GPCB_PLUGIN::PluginName ( ) const
inlineoverridevirtual

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

Implements PLUGIN.

Definition at line 55 of file gpcb_plugin.h.

56  {
57  return wxT( "Geda PCB" );
58  }
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 69 of file plugin.cpp.

Referenced by FP_LIB_TABLE::PrefetchLib().

70 {
71  (void) aLibraryPath;
72  (void) aProperties;
73 }
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.

Definition at line 54 of file plugin.cpp.

References not_implemented().

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

55 {
56  // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
57  not_implemented( this, __FUNCTION__ );
58 }
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

Friends And Related Function Documentation

friend class GPCB_FPL_CACHE
friend

Definition at line 49 of file gpcb_plugin.h.

Referenced by cacheLib().

Member Data Documentation

GPCB_FPL_CACHE* GPCB_PLUGIN::m_cache
protected
int GPCB_PLUGIN::m_ctl
protected

Definition at line 91 of file gpcb_plugin.h.

wxString GPCB_PLUGIN::m_error
protected

for throwing exceptions

Definition at line 88 of file gpcb_plugin.h.

wxString GPCB_PLUGIN::m_filename
protected

for saves only, name is in m_reader for loads

Definition at line 93 of file gpcb_plugin.h.

const PROPERTIES* GPCB_PLUGIN::m_props
protected

passed via Save() or Load(), no ownership, may be NULL.

Definition at line 89 of file gpcb_plugin.h.

Referenced by init().

LINE_READER* GPCB_PLUGIN::m_reader
protected

no ownership here.

Definition at line 92 of file gpcb_plugin.h.

Referenced by GPCB_PLUGIN().


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