KiCad PCB EDA Suite
FP_LIB_TABLE Class Reference

#include <fp_lib_table.h>

Inheritance diagram for FP_LIB_TABLE:
LIB_TABLE PROJECT::_ELEM FP_LIB_TABLE_GRID

Public Types

enum  SAVE_T { SAVE_OK, SAVE_SKIPPED }
 The set of return values from FootprintSave() below. More...
 

Public Member Functions

KICAD_T Type () override
 
virtual void Parse (LIB_TABLE_LEXER *aLexer) override
 Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objects. More...
 
virtual void Format (OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
 Generate the table in s-expression format to aOutput with an indention level of aIndentLevel. More...
 
 FP_LIB_TABLE (FP_LIB_TABLE *aFallBackTable=nullptr)
 Build a footprint library table by pre-pending this table fragment in front of aFallBackTable. More...
 
bool operator== (const FP_LIB_TABLE &aFpTable) const
 
bool operator!= (const FP_LIB_TABLE &r) const
 
const FP_LIB_TABLE_ROWFindRow (const wxString &aNickName, bool aCheckIfEnabled=false)
 Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table fragment. More...
 
void FootprintEnumerate (wxArrayString &aFootprintNames, const wxString &aNickname, bool aBestEfforts)
 Return a list of footprint names contained within the library given by aNickname. More...
 
long long GenerateTimestamp (const wxString *aNickname)
 Generate a hashed timestamp representing the last-mod-times of the library indicated by aNickname, or all libraries if aNickname is NULL. More...
 
void PrefetchLib (const wxString &aNickname)
 If possible, prefetches the specified library (e.g. More...
 
FOOTPRINTFootprintLoad (const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
 Load a footprint having aFootprintName from the library given by aNickname. More...
 
bool FootprintExists (const wxString &aNickname, const wxString &aFootprintName)
 Indicates whether or not the given footprint already exists in the given library. More...
 
const FOOTPRINTGetEnumeratedFootprint (const wxString &aNickname, const wxString &aFootprintName)
 A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management. More...
 
SAVE_T FootprintSave (const wxString &aNickname, const FOOTPRINT *aFootprint, bool aOverwrite=true)
 Write aFootprint to an existing library given by aNickname. More...
 
void FootprintDelete (const wxString &aNickname, const wxString &aFootprintName)
 Delete the aFootprintName from the library given by aNickname. More...
 
bool IsFootprintLibWritable (const wxString &aNickname)
 Return true if the library given by aNickname is writable. More...
 
void FootprintLibDelete (const wxString &aNickname)
 
void FootprintLibCreate (const wxString &aNickname)
 
FOOTPRINTFootprintLoadWithOptionalNickname (const LIB_ID &aFootprintId, bool aKeepUUID=false)
 Load a footprint having aFootprintId with possibly an empty nickname. More...
 
void Clear ()
 Delete all rows. More...
 
bool operator== (const LIB_TABLE &r) const
 Compares this table against another. More...
 
bool operator!= (const LIB_TABLE &r) const
 
unsigned GetCount () const
 Get the number of rows contained in the table. More...
 
LIB_TABLE_ROWAt (unsigned aIndex)
 Get the 'n'th LIB_TABLE_ROW object. More...
 
const LIB_TABLE_ROWAt (unsigned aIndex) const
 Get the 'n'th LIB_TABLE_ROW object. More...
 
bool IsEmpty (bool aIncludeFallback=true)
 Return true if the table is empty. More...
 
const wxString GetDescription (const wxString &aNickname)
 
bool HasLibrary (const wxString &aNickname, bool aCheckEnabled=false) const
 Test for the existence of aNickname in the library table. More...
 
std::vector< wxString > GetLogicalLibs ()
 Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE. More...
 
wxString GetFullURI (const wxString &aLibNickname, bool aExpandEnvVars=true) const
 Return the full URI of the library mapped to aLibNickname. More...
 
bool InsertRow (LIB_TABLE_ROW *aRow, bool doReplace=false)
 Adds aRow if it does not already exist or if doReplace is true. More...
 
bool RemoveRow (LIB_TABLE_ROW *aRow)
 Removes a row from the table. More...
 
const LIB_TABLE_ROWFindRowByURI (const wxString &aURI)
 
void Load (const wxString &aFileName)
 Load the library table using the path defined by aFileName aFallBackTable. More...
 
void Save (const wxString &aFileName) const
 Write this library table to aFileName in s-expression form. More...
 

Static Public Member Functions

static bool LoadGlobalTable (FP_LIB_TABLE &aTable)
 Load the global footprint library table into aTable. More...
 
static wxString GetGlobalTableFileName ()
 
static const wxString GlobalPathEnvVariableName ()
 Return the name of the environment variable used to hold the directory of locally installed "KiCad sponsored" system footprint libraries. More...
 
static PROPERTIESParseOptions (const std::string &aOptionsList)
 Parses aOptionsList and places the result into a PROPERTIES object which is returned. More...
 
static UTF8 FormatOptions (const PROPERTIES *aProperties)
 Returns a list of options from the aProperties parameter. More...
 

Protected Types

typedef std::map< wxString, int > INDEX
 this is a non-owning index into the LIB_TABLE_ROWS table More...
 
typedef INDEX::iterator INDEX_ITER
 
typedef INDEX::const_iterator INDEX_CITER
 
typedef INDEX::value_type INDEX_VALUE
 

Protected Member Functions

LIB_TABLE_ROWfindRow (const wxString &aNickname, bool aCheckIfEnabled=false) const
 Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment, else NULL. More...
 
void reindex ()
 
void ensureIndex ()
 

Protected Attributes

LIB_TABLE_ROWS rows
 
INDEX nickIndex
 this particular key is the nickName within each row. More...
 
LIB_TABLEfallBack
 
std::recursive_mutex m_nickIndexMutex
 Mutex to protect access to the nickIndex variable. More...
 

Friends

class FP_LIB_TABLE_GRID
 

Detailed Description

Definition at line 96 of file fp_lib_table.h.

Member Typedef Documentation

◆ INDEX

typedef std::map<wxString,int> LIB_TABLE::INDEX
protectedinherited

this is a non-owning index into the LIB_TABLE_ROWS table

Definition at line 534 of file lib_table_base.h.

◆ INDEX_CITER

typedef INDEX::const_iterator LIB_TABLE::INDEX_CITER
protectedinherited

Definition at line 536 of file lib_table_base.h.

◆ INDEX_ITER

typedef INDEX::iterator LIB_TABLE::INDEX_ITER
protectedinherited

Definition at line 535 of file lib_table_base.h.

◆ INDEX_VALUE

typedef INDEX::value_type LIB_TABLE::INDEX_VALUE
protectedinherited

Definition at line 537 of file lib_table_base.h.

Member Enumeration Documentation

◆ SAVE_T

The set of return values from FootprintSave() below.

Enumerator
SAVE_OK 
SAVE_SKIPPED 

Definition at line 198 of file fp_lib_table.h.

Constructor & Destructor Documentation

◆ FP_LIB_TABLE()

FP_LIB_TABLE::FP_LIB_TABLE ( FP_LIB_TABLE aFallBackTable = nullptr)

Build a footprint library table by pre-pending this table fragment in front of aFallBackTable.

Loading of this table fragment is done by using Parse().

Parameters
aFallBackTableis another FP_LIB_TABLE which is searched only when a row is not found in this table. No ownership is taken of aFallBackTable.

Definition at line 65 of file fp_lib_table.cpp.

65  :
66  LIB_TABLE( aFallBackTable )
67 {
68  // not copying fall back, simply search aFallBackTable separately
69  // if "nickName not found".
70 }
LIB_TABLE(LIB_TABLE *aFallBackTable=nullptr)
Build a library table by pre-pending this table fragment in front of aFallBackTable.

Member Function Documentation

◆ At() [1/2]

LIB_TABLE_ROW& LIB_TABLE::At ( unsigned  aIndex)
inlineinherited

Get the 'n'th LIB_TABLE_ROW object.

Parameters
aIndexindex of row (must exist: from 0 to GetCount() - 1)
Returns
reference to the row

Definition at line 365 of file lib_table_base.h.

366  {
367  return rows[aIndex];
368  }
LIB_TABLE_ROWS rows

References LIB_TABLE::rows.

Referenced by SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), and SCH::IFACE::SaveFileAs().

◆ At() [2/2]

const LIB_TABLE_ROW& LIB_TABLE::At ( unsigned  aIndex) const
inlineinherited

Get the 'n'th LIB_TABLE_ROW object.

Parameters
aIndexindex of row (must exist: from 0 to GetCount() - 1)
Returns
reference to the row

Definition at line 373 of file lib_table_base.h.

374  {
375  return rows[aIndex];
376  }
LIB_TABLE_ROWS rows

References LIB_TABLE::rows.

◆ Clear()

void LIB_TABLE::Clear ( )
inlineinherited

Delete all rows.

Definition at line 320 of file lib_table_base.h.

321  {
322  std::lock_guard<std::recursive_mutex> lock( m_nickIndexMutex );
323 
324  rows.clear();
325  nickIndex.clear();
326  }
LIB_TABLE_ROWS rows
std::recursive_mutex m_nickIndexMutex
Mutex to protect access to the nickIndex variable.
INDEX nickIndex
this particular key is the nickName within each row.

References LIB_TABLE::m_nickIndexMutex, LIB_TABLE::nickIndex, and LIB_TABLE::rows.

Referenced by PANEL_FP_LIB_TABLE::TransferDataFromWindow(), and PANEL_SYM_LIB_TABLE::TransferDataFromWindow().

◆ ensureIndex()

void LIB_TABLE::ensureIndex ( )
inlineprotectedinherited

Definition at line 515 of file lib_table_base.h.

516  {
517  std::lock_guard<std::recursive_mutex> lock( m_nickIndexMutex );
518 
519  // The dialog lib table editor may not maintain the nickIndex.
520  // Lazy indexing may be required. To handle lazy indexing, we must enforce
521  // that "nickIndex" is either empty or accurate, but never inaccurate.
522  if( !nickIndex.size() )
523  reindex();
524  }
void reindex()
std::recursive_mutex m_nickIndexMutex
Mutex to protect access to the nickIndex variable.
INDEX nickIndex
this particular key is the nickName within each row.

References LIB_TABLE::m_nickIndexMutex, LIB_TABLE::nickIndex, and LIB_TABLE::reindex().

Referenced by LIB_TABLE::findRow(), LIB_TABLE::FindRowByURI(), and LIB_TABLE::InsertRow().

◆ FindRow()

const FP_LIB_TABLE_ROW * FP_LIB_TABLE::FindRow ( const wxString &  aNickName,
bool  aCheckIfEnabled = false 
)

Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table fragment.

If aCheckIfEnabled is true, the library will be ignored even if it is disabled. Otherwise, the row found will be returned even if entry is disabled.

The PLUGIN is loaded and attached to the "plugin" field of the FP_LIB_TABLE_ROW if not already loaded.

Parameters
aNickNameis the name of library nickname to find.
aCheckIfEnabledis the flag to check if the library found is enabled.
Returns
the library NickName if found.
Exceptions
IO_ERRORif aNickName cannot be found.

Definition at line 291 of file fp_lib_table.cpp.

292 {
293  // Do not optimize this code. Is done this way specifically to fix a runtime
294  // error with clang 4.0.1.
295  LIB_TABLE_ROW* ltrow = findRow( aNickname, aCheckIfEnabled );
296  FP_LIB_TABLE_ROW* row = dynamic_cast< FP_LIB_TABLE_ROW* >( ltrow );
297 
298  if( !row )
299  {
300  wxString msg = wxString::Format( _( "fp-lib-table files contain no library named '%s'." ),
301  aNickname );
302 
303  THROW_IO_ERROR( msg );
304  }
305 
306  // We've been 'lazy' up until now, but it cannot be deferred any longer,
307  // instantiate a PLUGIN of the proper kind if it is not already in this
308  // FP_LIB_TABLE_ROW.
309  if( !row->plugin )
310  row->setPlugin( IO_MGR::PluginFind( row->type ) );
311 
312  return row;
313 }
void setPlugin(PLUGIN *aPlugin)
Definition: fp_lib_table.h:84
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
#define _(s)
LIB_TABLE_ROW * findRow(const wxString &aNickname, bool aCheckIfEnabled=false) const
Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment,...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Return a PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: io_mgr.cpp:58
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, LIB_TABLE::findRow(), Format(), FP_LIB_TABLE_ROW::plugin, IO_MGR::PluginFind(), FP_LIB_TABLE_ROW::setPlugin(), THROW_IO_ERROR, and FP_LIB_TABLE_ROW::type.

Referenced by FP_TREE_MODEL_ADAPTER::AddLibraries(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), FootprintDelete(), FootprintEnumerate(), FootprintExists(), FootprintLibCreate(), FootprintLibDelete(), FootprintLoad(), FootprintSave(), GenerateTimestamp(), GetEnumeratedFootprint(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), IsFootprintLibWritable(), PrefetchLib(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), and FOOTPRINT_VIEWER_FRAME::UpdateTitle().

◆ findRow()

LIB_TABLE_ROW * LIB_TABLE::findRow ( const wxString &  aNickname,
bool  aCheckIfEnabled = false 
) const
protectedinherited

Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment, else NULL.

Parameters
aNicknameis the name of the library table entry to find.
aCheckIfEnabledis a flag to check if the library table entry is enabled.
Returns
a pointer to the LIB_TABLE_ROW found.

Definition at line 183 of file lib_table_base.cpp.

184 {
185  LIB_TABLE_ROW* row = nullptr;
186  LIB_TABLE* cur = (LIB_TABLE*) this;
187 
188  std::lock_guard<std::recursive_mutex> lock( m_nickIndexMutex );
189 
190  do
191  {
192  cur->ensureIndex();
193 
194  for( const std::pair<const wxString, int>& entry : cur->nickIndex )
195  {
196  if( entry.first == aNickName )
197  {
198  row = &cur->rows[entry.second];
199 
200  if( !aCheckIfEnabled || ( aCheckIfEnabled && row->GetIsEnabled() ) )
201  return row;
202  }
203  }
204 
205  // Repeat, this time looking for names that were "fixed" by legacy versions because
206  // the old eeschema file format didn't support spaces in tokens.
207  for( const std::pair<const wxString, int>& entry : cur->nickIndex )
208  {
209  wxString legacyLibName = entry.first;
210  legacyLibName.Replace( " ", "_" );
211 
212  if( legacyLibName == aNickName )
213  {
214  row = &cur->rows[entry.second];
215 
216  if( !aCheckIfEnabled || ( aCheckIfEnabled && row->GetIsEnabled() ) )
217  return row;
218  }
219  }
220 
221  // not found, search fall back table(s), if any
222  } while( ( cur = cur->fallBack ) != nullptr );
223 
224  return nullptr; // not found
225 }
void ensureIndex()
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
LIB_TABLE_ROWS rows
LIB_TABLE * fallBack
bool GetIsEnabled() const
std::recursive_mutex m_nickIndexMutex
Mutex to protect access to the nickIndex variable.
INDEX nickIndex
this particular key is the nickName within each row.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.

References LIB_TABLE::ensureIndex(), LIB_TABLE::fallBack, LIB_TABLE_ROW::GetIsEnabled(), LIB_TABLE::m_nickIndexMutex, LIB_TABLE::nickIndex, and LIB_TABLE::rows.

Referenced by FindRow(), SYMBOL_LIB_TABLE::FindRow(), LIB_TABLE::GetDescription(), LIB_TABLE::GetFullURI(), and LIB_TABLE::HasLibrary().

◆ FindRowByURI()

const LIB_TABLE_ROW * LIB_TABLE::FindRowByURI ( const wxString &  aURI)
inherited
Returns
a LIB_TABLE_ROW pointer if aURI is found in this table or in any chained fallBack table fragments, else NULL.

Definition at line 228 of file lib_table_base.cpp.

229 {
230  LIB_TABLE* cur = this;
231 
232  do
233  {
234  cur->ensureIndex();
235 
236  for( unsigned i = 0; i < cur->rows.size(); i++ )
237  {
238  wxString tmp = cur->rows[i].GetFullURI( true );
239 
240  if( tmp.Find( "://" ) != wxNOT_FOUND )
241  {
242  if( tmp == aURI )
243  return &cur->rows[i]; // found as URI
244  }
245  else
246  {
247  wxFileName fn = aURI;
248 
249  // This will also test if the file is a symlink so if we are comparing
250  // a symlink to the same real file, the comparison will be true. See
251  // wxFileName::SameAs() in the wxWidgets source.
252  if( fn == wxFileName( tmp ) )
253  return &cur->rows[i]; // found as full path and file name
254  }
255  }
256 
257  // not found, search fall back table(s), if any
258  } while( ( cur = cur->fallBack ) != nullptr );
259 
260  return nullptr; // not found
261 }
void ensureIndex()
LIB_TABLE_ROWS rows
LIB_TABLE * fallBack
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.

References LIB_TABLE::ensureIndex(), LIB_TABLE::fallBack, and LIB_TABLE::rows.

Referenced by FOOTPRINT_EDIT_FRAME::KiwayMailIn(), and SYMBOL_EDIT_FRAME::KiwayMailIn().

◆ FootprintDelete()

void FP_LIB_TABLE::FootprintDelete ( const wxString &  aNickname,
const wxString &  aFootprintName 
)

Delete the aFootprintName from the library given by aNickname.

Parameters
aNicknameis a locator for the "library", it is a "name" in LIB_TABLE_ROW.
aFootprintNameis the name of a footprint to delete from the specified library.
Exceptions
IO_ERRORif there is a problem finding the footprint or the library, or deleting it.

Definition at line 410 of file fp_lib_table.cpp.

411 {
412  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
413  wxASSERT( (PLUGIN*) row->plugin );
414  return row->plugin->FootprintDelete( row->GetFullURI( true ), aFootprintName,
415  row->GetProperties() );
416 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetProperties(), and FP_LIB_TABLE_ROW::plugin.

Referenced by FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary().

◆ FootprintEnumerate()

void FP_LIB_TABLE::FootprintEnumerate ( wxArrayString &  aFootprintNames,
const wxString &  aNickname,
bool  aBestEfforts 
)

Return a list of footprint names contained within the library given by aNickname.

Parameters
aFootprintNamesis the list to fill with the footprint names found in aNickname
aNicknameis a locator for the "library", it is a "name" in LIB_TABLE_ROW.
aBestEffortsif true, don't throw on errors.
Exceptions
IO_ERRORif the library cannot be found, or footprint cannot be loaded.

Definition at line 273 of file fp_lib_table.cpp.

275 {
276  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
277  wxASSERT( (PLUGIN*) row->plugin );
278  row->plugin->FootprintEnumerate( aFootprintNames, row->GetFullURI( true ), aBestEfforts,
279  row->GetProperties() );
280 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetProperties(), and FP_LIB_TABLE_ROW::plugin.

Referenced by GetFootprints(), guessNickname(), and FOOTPRINT_LIST_IMPL::joinWorkers().

◆ FootprintExists()

bool FP_LIB_TABLE::FootprintExists ( const wxString &  aNickname,
const wxString &  aFootprintName 
)

Indicates whether or not the given footprint already exists in the given library.

Definition at line 351 of file fp_lib_table.cpp.

352 {
353  try
354  {
355  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
356  wxASSERT( (PLUGIN*) row->plugin );
357 
358  return row->plugin->FootprintExists( row->GetFullURI( true ), aFootprintName,
359  row->GetProperties() );
360  }
361  catch( ... )
362  {
363  return false;
364  }
365 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetProperties(), and FP_LIB_TABLE_ROW::plugin.

Referenced by FOOTPRINT_EDITOR_CONTROL::PasteFootprint(), and FOOTPRINT_EDIT_FRAME::SaveFootprintAs().

◆ FootprintLibCreate()

void FP_LIB_TABLE::FootprintLibCreate ( const wxString &  aNickname)

Definition at line 435 of file fp_lib_table.cpp.

436 {
437  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
438  wxASSERT( (PLUGIN*) row->plugin );
439  row->plugin->FootprintLibCreate( row->GetFullURI( true ), row->GetProperties() );
440 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetProperties(), and FP_LIB_TABLE_ROW::plugin.

◆ FootprintLibDelete()

void FP_LIB_TABLE::FootprintLibDelete ( const wxString &  aNickname)

Definition at line 427 of file fp_lib_table.cpp.

428 {
429  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
430  wxASSERT( (PLUGIN*) row->plugin );
431  row->plugin->FootprintLibDelete( row->GetFullURI( true ), row->GetProperties() );
432 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetProperties(), and FP_LIB_TABLE_ROW::plugin.

◆ FootprintLoad()

FOOTPRINT * FP_LIB_TABLE::FootprintLoad ( const wxString &  aNickname,
const wxString &  aFootprintName,
bool  aKeepUUID = false 
)

Load a footprint having aFootprintName from the library given by aNickname.

Parameters
aNicknameis a locator for the "library", it is a "name" in LIB_TABLE_ROW.
aFootprintNameis the name of the footprint to load.
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. Used only in kicad_plugin
Returns
the footprint 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.

Definition at line 368 of file fp_lib_table.cpp.

370 {
371  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
372  wxASSERT( (PLUGIN*) row->plugin );
373 
374  FOOTPRINT* ret = row->plugin->FootprintLoad( row->GetFullURI( true ), aFootprintName,
375  aKeepUUID, row->GetProperties() );
376 
377  setLibNickname( ret, row->GetNickName(), aFootprintName );
378 
379  return ret;
380 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
static void setLibNickname(FOOTPRINT *aModule, const wxString &aNickname, const wxString &aFootprintName)
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const wxString & GetNickName() const
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetNickName(), LIB_TABLE_ROW::GetProperties(), FP_LIB_TABLE_ROW::plugin, and setLibNickname().

Referenced by FootprintLoadWithOptionalNickname(), and FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint().

◆ FootprintLoadWithOptionalNickname()

FOOTPRINT * FP_LIB_TABLE::FootprintLoadWithOptionalNickname ( const LIB_ID aFootprintId,
bool  aKeepUUID = false 
)

Load a footprint having aFootprintId with possibly an empty nickname.

Parameters
aFootprintIdthe [nickname] and footprint name of the footprint to load.
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 used only in kicad_plugin
Returns
the FOOTPRINT 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.
PARSE_ERRORif aFootprintId is not parsed OK.

Definition at line 443 of file fp_lib_table.cpp.

445 {
446  wxString nickname = aFootprintId.GetLibNickname();
447  wxString fpname = aFootprintId.GetLibItemName();
448 
449  if( nickname.size() )
450  {
451  return FootprintLoad( nickname, fpname, aKeepUUID );
452  }
453 
454  // nickname is empty, sequentially search (alphabetically) all libs/nicks for first match:
455  else
456  {
457  std::vector<wxString> nicks = GetLogicalLibs();
458 
459  // Search each library going through libraries alphabetically.
460  for( unsigned i = 0; i < nicks.size(); ++i )
461  {
462  // FootprintLoad() returns NULL on not found, does not throw exception
463  // unless there's an IO_ERROR.
464  FOOTPRINT* ret = FootprintLoad( nicks[i], fpname, aKeepUUID );
465 
466  if( ret )
467  return ret;
468  }
469 
470  return NULL;
471  }
472 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
#define NULL
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.

References FootprintLoad(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), LIB_TABLE::GetLogicalLibs(), and NULL.

Referenced by PCB_BASE_FRAME::loadFootprint().

◆ FootprintSave()

FP_LIB_TABLE::SAVE_T FP_LIB_TABLE::FootprintSave ( const wxString &  aNickname,
const FOOTPRINT aFootprint,
bool  aOverwrite = true 
)

Write aFootprint to an existing library given by aNickname.

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

Parameters
aNicknameis a locator for the "library", it is a "name" in LIB_TABLE_ROW.
aFootprintis what to store in the library. The caller continues to own the footprint after this call.
aOverwritewhen true means overwrite any existing footprint by the same name, else if false means skip the write and return SAVE_SKIPPED.
Returns
SAVE_OK or SAVE_SKIPPED. If error saving, then IO_ERROR is thrown.
Exceptions
IO_ERRORif there is a problem saving.

Definition at line 383 of file fp_lib_table.cpp.

385 {
386  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
387  wxASSERT( (PLUGIN*) row->plugin );
388 
389  if( !aOverwrite )
390  {
391  // Try loading the footprint to see if it already exists, caller wants overwrite
392  // protection, which is atypical, not the default.
393 
394  wxString fpname = aFootprint->GetFPID().GetLibItemName();
395 
396  std::unique_ptr<FOOTPRINT> footprint( row->plugin->FootprintLoad( row->GetFullURI( true ),
397  fpname,
398  row->GetProperties() ) );
399 
400  if( footprint.get() )
401  return SAVE_SKIPPED;
402  }
403 
404  row->plugin->FootprintSave( row->GetFullURI( true ), aFootprint, row->GetProperties() );
405 
406  return SAVE_OK;
407 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const LIB_ID & GetFPID() const
Definition: footprint.h:185
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), FOOTPRINT::GetFPID(), LIB_TABLE_ROW::GetFullURI(), LIB_ID::GetLibItemName(), LIB_TABLE_ROW::GetProperties(), FP_LIB_TABLE_ROW::plugin, SAVE_OK, and SAVE_SKIPPED.

Referenced by PCB_EDIT_FRAME::ExportFootprintsToLibrary(), and FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary().

◆ Format()

void FP_LIB_TABLE::Format ( OUTPUTFORMATTER aOutput,
int  aIndentLevel 
) const
overridevirtual

Generate the table in s-expression format to aOutput with an indention level of aIndentLevel.

Parameters
aOutputis the OUTPUTFORMATTER to format the table into.
aIndentLevelis the indentation level (2 spaces) to indent.
Exceptions
IO_ERRORif an I/O error occurs during output.
boost::interprocess::lock_exceptif separate process attempt to access the table.

Implements LIB_TABLE.

Definition at line 234 of file fp_lib_table.cpp.

235 {
236  aOutput->Print( aIndentLevel, "(fp_lib_table\n" );
237 
238  for( LIB_TABLE_ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
239  it->Format( aOutput, aIndentLevel+1 );
240 
241  aOutput->Print( aIndentLevel, ")\n" );
242 }
LIB_TABLE_ROWS rows
LIB_TABLE_ROWS::const_iterator LIB_TABLE_ROWS_CITER
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:408

References OUTPUTFORMATTER::Print(), and LIB_TABLE::rows.

Referenced by FOOTPRINT_ASYNC_LOADER::Start().

◆ FormatOptions()

UTF8 LIB_TABLE::FormatOptions ( const PROPERTIES aProperties)
staticinherited

Returns a list of options from the aProperties parameter.

The name=value pairs will be separated with the '|' character. The =value portion may not be present. You might expect something like "name1=value1|name2=value2|flag_me". Notice that flag_me does not have a value. This is ok.

Parameters
aPropertiesis the PROPERTIES to format or NULL. If NULL the returned string will be empty.

Definition at line 411 of file lib_table_base.cpp.

412 {
413  UTF8 ret;
414 
415  if( aProperties )
416  {
417  for( PROPERTIES::const_iterator it = aProperties->begin(); it != aProperties->end(); ++it )
418  {
419  const std::string& name = it->first;
420 
421  const UTF8& value = it->second;
422 
423  if( ret.size() )
424  ret += OPT_SEP;
425 
426  ret += name;
427 
428  // the separation between name and value is '='
429  if( value.size() )
430  {
431  ret += '=';
432 
433  for( std::string::const_iterator si = value.begin(); si != value.end(); ++si )
434  {
435  // escape any separator in the value.
436  if( *si == OPT_SEP )
437  ret += '\\';
438 
439  ret += *si;
440  }
441  }
442  }
443  }
444 
445  return ret;
446 }
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
const char * name
Definition: DXF_plotter.cpp:59
std::string::const_iterator end() const
Definition: utf8.h:193
std::string::const_iterator begin() const
Definition: utf8.h:192
std::string::size_type size() const
Definition: utf8.h:110
#define OPT_SEP
options separator character

References UTF8::begin(), UTF8::end(), name, OPT_SEP, and UTF8::size().

Referenced by DIALOG_FP_PLUGIN_OPTIONS::TransferDataFromWindow().

◆ GenerateTimestamp()

long long FP_LIB_TABLE::GenerateTimestamp ( const wxString *  aNickname)

Generate a hashed timestamp representing the last-mod-times of the library indicated by aNickname, or all libraries if aNickname is NULL.

Definition at line 245 of file fp_lib_table.cpp.

246 {
247  long long hash = 0;
248 
249  if( aNickname )
250  {
251  const FP_LIB_TABLE_ROW* row = FindRow( *aNickname, true );
252 
253  wxCHECK( row && row->plugin, hash );
254 
255  return row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) ) +
256  wxHashTable::MakeKey( *aNickname );
257  }
258 
259  for( const wxString& nickname : GetLogicalLibs() )
260  {
261  const FP_LIB_TABLE_ROW* row = FindRow( nickname, true );
262 
263  wxCHECK2( row && row->plugin, continue );
264 
265  hash += row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) ) +
266  wxHashTable::MakeKey( nickname );
267  }
268 
269  return hash;
270 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE::GetLogicalLibs(), and FP_LIB_TABLE_ROW::plugin.

Referenced by FOOTPRINT_LIST_IMPL::ReadFootprintFiles().

◆ GetCount()

unsigned LIB_TABLE::GetCount ( ) const
inlineinherited

Get the number of rows contained in the table.

Definition at line 355 of file lib_table_base.h.

356  {
357  return rows.size();
358  }
LIB_TABLE_ROWS rows

References LIB_TABLE::rows.

Referenced by BOOST_AUTO_TEST_CASE(), FP_TREE_SYNCHRONIZING_ADAPTER::GetLibrariesCount(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), and SCH::IFACE::SaveFileAs().

◆ GetDescription()

const wxString LIB_TABLE::GetDescription ( const wxString &  aNickname)
inherited
Returns
the library description from aNickname, or an empty string if aNickname does not exist.

Definition at line 147 of file lib_table_base.cpp.

148 {
149  // Use "no exception" form of find row and ignore disabled flag.
150  const LIB_TABLE_ROW* row = findRow( aNickname );
151 
152  if( row )
153  return row->GetDescr();
154  else
155  return wxEmptyString;
156 }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString & GetDescr() const
Return the description of the library referenced by this row.
LIB_TABLE_ROW * findRow(const wxString &aNickname, bool aCheckIfEnabled=false) const
Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment,...

References LIB_TABLE::findRow(), and LIB_TABLE_ROW::GetDescr().

Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_TREE_MODEL_ADAPTER::AddLibrary(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_EDIT_FRAME::saveSymbolAs(), and PCB_BASE_FRAME::SelectLibrary().

◆ GetEnumeratedFootprint()

const FOOTPRINT * FP_LIB_TABLE::GetEnumeratedFootprint ( const wxString &  aNickname,
const wxString &  aFootprintName 
)

A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.

The return value is const to allow it to return a reference to a cached item.

Definition at line 340 of file fp_lib_table.cpp.

342 {
343  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
344  wxASSERT( (PLUGIN*) row->plugin );
345 
346  return row->plugin->GetEnumeratedFootprint( row->GetFullURI( true ), aFootprintName,
347  row->GetProperties() );
348 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetProperties(), and FP_LIB_TABLE_ROW::plugin.

Referenced by FOOTPRINT_PREVIEW_PANEL::DisplayFootprint(), FOOTPRINT_INFO_GENERATOR::GenerateHtml(), and FOOTPRINT_INFO_IMPL::load().

◆ GetFullURI()

wxString LIB_TABLE::GetFullURI ( const wxString &  aLibNickname,
bool  aExpandEnvVars = true 
) const
inherited

Return the full URI of the library mapped to aLibNickname.

Definition at line 170 of file lib_table_base.cpp.

171 {
172  const LIB_TABLE_ROW* row = findRow( aNickname, true );
173 
174  wxString retv;
175 
176  if( row )
177  retv = row->GetFullURI( aExpandEnvVars );
178 
179  return retv;
180 }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
LIB_TABLE_ROW * findRow(const wxString &aNickname, bool aCheckIfEnabled=false) const
Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment,...

References LIB_TABLE::findRow(), and LIB_TABLE_ROW::GetFullURI().

Referenced by CVPCB_MAINFRAME::DisplayStatus(), SCH_EDIT_FRAME::LoadSheetFromFile(), NETLIST_EXPORTER_XML::makeLibraries(), and FOOTPRINT_EDITOR_CONTROL::SaveAs().

◆ GetGlobalTableFileName()

wxString FP_LIB_TABLE::GetGlobalTableFileName ( )
static
Returns
the platform specific global footprint library path and file name.

Definition at line 525 of file fp_lib_table.cpp.

526 {
527  wxFileName fn;
528 
530  fn.SetName( global_tbl_name );
531 
532  return fn.GetFullPath();
533 }
static const wxChar global_tbl_name[]
static wxString GetUserSettingsPath()
Return the user configuration path used to store KiCad's configuration files.

References SETTINGS_MANAGER::GetUserSettingsPath(), and global_tbl_name.

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::GetGlobalTableFileName(), InvokePcbLibTableEditor(), LoadGlobalTable(), PCB::IFACE::OnKifaceStart(), and DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow().

◆ GetLogicalLibs()

std::vector< wxString > LIB_TABLE::GetLogicalLibs ( )
inherited

Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.

Definition at line 264 of file lib_table_base.cpp.

265 {
266  // Only return unique logical library names. Use std::set::insert() to
267  // quietly reject any duplicates, which can happen when encountering a duplicate
268  // nickname from one of the fall back table(s).
269 
270  std::set< wxString > unique;
271  std::vector< wxString > ret;
272  const LIB_TABLE* cur = this;
273 
274  do
275  {
276  for( LIB_TABLE_ROWS_CITER it = cur->rows.begin(); it!=cur->rows.end(); ++it )
277  {
278  if( it->GetIsEnabled() )
279  {
280  unique.insert( it->GetNickName() );
281  }
282  }
283 
284  } while( ( cur = cur->fallBack ) != nullptr );
285 
286  ret.reserve( unique.size() );
287 
288  // return a sorted, unique set of nicknames in a std::vector<wxString> to caller
289  for( std::set< wxString >::const_iterator it = unique.begin(); it!=unique.end(); ++it )
290  {
291  ret.push_back( *it );
292  }
293 
294  // We want to allow case-sensitive duplicates but sort by case-insensitive ordering
295  std::sort( ret.begin(), ret.end(), []( const wxString& lhs, const wxString& rhs )
296  {
297  return lhs.CmpNoCase( rhs ) < 0;
298  } );
299 
300  return ret;
301 }
LIB_TABLE_ROWS rows
LIB_TABLE * fallBack
LIB_TABLE_ROWS::const_iterator LIB_TABLE_ROWS_CITER
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.

References LIB_TABLE::fallBack, and LIB_TABLE::rows.

Referenced by FP_TREE_MODEL_ADAPTER::AddLibraries(), CVPCB_MAINFRAME::BuildLibrariesListBox(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FootprintLoadWithOptionalNickname(), GenerateTimestamp(), GetFootprintLibraries(), SYMBOL_LIBRARY_MANAGER::GetLibraryCount(), SYMBOL_LIB_TABLE::GetModifyHash(), guessNickname(), CVPCB_MAINFRAME::LoadFootprintFiles(), SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname(), FOOTPRINT_VIEWER_FRAME::OnActivate(), SYMBOL_VIEWER_FRAME::OnSelectSymbol(), SCH_BASE_FRAME::PickSymbolFromLibTree(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_EDIT_FRAME::saveSymbolAs(), PCB_BASE_FRAME::SelectLibrary(), FOOTPRINT_LIST_IMPL::startWorkers(), and FP_TREE_SYNCHRONIZING_ADAPTER::Sync().

◆ GlobalPathEnvVariableName()

const wxString FP_LIB_TABLE::GlobalPathEnvVariableName ( )
static

Return the name of the environment variable used to hold the directory of locally installed "KiCad sponsored" system footprint libraries.

These can be either legacy or pretty format. The only thing special about this particular environment variable is that it is set automatically by KiCad on program start up, if it is not set already in the environment.

Definition at line 475 of file fp_lib_table.cpp.

476 {
477  return "KICAD6_FOOTPRINT_DIR";
478 }

Referenced by DIALOG_CONFIG_EQUFILES::Init(), and PANEL_FP_LIB_TABLE::populateEnvironReadOnlyTable().

◆ HasLibrary()

bool LIB_TABLE::HasLibrary ( const wxString &  aNickname,
bool  aCheckEnabled = false 
) const
inherited

Test for the existence of aNickname in the library table.

Parameters
aCheckEnabledif true will only return true for enabled libraries
Returns
true if a library aNickname exists in the table.

Definition at line 159 of file lib_table_base.cpp.

160 {
161  const LIB_TABLE_ROW* row = findRow( aNickname, aCheckEnabled );
162 
163  if( row == nullptr )
164  return false;
165 
166  return true;
167 }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
LIB_TABLE_ROW * findRow(const wxString &aNickname, bool aCheckIfEnabled=false) const
Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment,...

References LIB_TABLE::findRow().

Referenced by SYMBOL_EDIT_FRAME::addLibTableEntry(), CVPCB_MAINFRAME::DisplayStatus(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), SYMBOL_EDIT_FRAME::KiwayMailIn(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), SCH_ALTIUM_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), SCH_EDIT_FRAME::LoadSheetFromFile(), NETLIST_EXPORTER_XML::makeLibraries(), SCH_BASE_FRAME::PickSymbolFromLibTree(), SYMBOL_VIEWER_FRAME::ShowModal(), FOOTPRINT_VIEWER_FRAME::ShowModal(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), ERC_TESTER::TestLibSymbolIssues(), and SCH_SCREEN::UpdateSymbolLinks().

◆ InsertRow()

bool LIB_TABLE::InsertRow ( LIB_TABLE_ROW aRow,
bool  doReplace = false 
)
inherited

Adds aRow if it does not already exist or if doReplace is true.

If doReplace is not true and the key for aRow already exists, the function fails and returns false.

The key for the table is the nickName, and all in this table must be unique.

Parameters
aRowis the new row to insert, or to forcibly add if doReplace is true.
doReplaceif true, means insert regardless of whether aRow's key already exists. If false, then fail if the key already exists.
Returns
bool - true if the operation succeeded.

Definition at line 304 of file lib_table_base.cpp.

305 {
306  std::lock_guard<std::recursive_mutex> lock( m_nickIndexMutex );
307 
308  ensureIndex();
309 
310  INDEX_CITER it = nickIndex.find( aRow->GetNickName() );
311 
312  if( it == nickIndex.end() )
313  {
314  rows.push_back( aRow );
315  nickIndex.insert( INDEX_VALUE( aRow->GetNickName(), rows.size() - 1 ) );
316  return true;
317  }
318 
319  if( doReplace )
320  {
321  rows.replace( it->second, aRow );
322  return true;
323  }
324 
325  return false;
326 }
void ensureIndex()
INDEX::const_iterator INDEX_CITER
LIB_TABLE_ROWS rows
INDEX::value_type INDEX_VALUE
const wxString & GetNickName() const
std::recursive_mutex m_nickIndexMutex
Mutex to protect access to the nickIndex variable.
INDEX nickIndex
this particular key is the nickName within each row.

References LIB_TABLE::ensureIndex(), LIB_TABLE_ROW::GetNickName(), LIB_TABLE::m_nickIndexMutex, LIB_TABLE::nickIndex, and LIB_TABLE::rows.

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_LIBRARY_MANAGER::addLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), LIB_TABLE_TEST_FIXTURE::LIB_TABLE_TEST_FIXTURE(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), SCH_ALTIUM_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), PCB_EDIT_FRAME::OpenProjectFiles(), Parse(), and SYMBOL_LIB_TABLE::Parse().

◆ IsEmpty()

bool LIB_TABLE::IsEmpty ( bool  aIncludeFallback = true)
inherited

Return true if the table is empty.

Parameters
aIncludeFallbackis used to determine if the fallback table should be included in the test.
Returns
true if the footprint library table is empty.

Definition at line 138 of file lib_table_base.cpp.

139 {
140  if( !aIncludeFallback || !fallBack )
141  return rows.empty();
142 
143  return rows.empty() && fallBack->IsEmpty( true );
144 }
LIB_TABLE_ROWS rows
LIB_TABLE * fallBack
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.

References LIB_TABLE::fallBack, LIB_TABLE::IsEmpty(), and LIB_TABLE::rows.

Referenced by BOOST_AUTO_TEST_CASE(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), LIB_TABLE::IsEmpty(), PCB_EDIT_FRAME::LoadFootprints(), and SCH_EDIT_FRAME::LoadSheetFromFile().

◆ IsFootprintLibWritable()

bool FP_LIB_TABLE::IsFootprintLibWritable ( const wxString &  aNickname)

Return true if the library given by aNickname is writable.

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

Exceptions
IO_ERRORif no library at aLibraryPath exists.

Definition at line 419 of file fp_lib_table.cpp.

420 {
421  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
422  wxASSERT( (PLUGIN*) row->plugin );
423  return row->plugin->IsFootprintLibWritable( row->GetFullURI( true ) );
424 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267

References FindRow(), LIB_TABLE_ROW::GetFullURI(), and FP_LIB_TABLE_ROW::plugin.

Referenced by FOOTPRINT_EDIT_FRAME::UpdateTitle().

◆ Load()

void LIB_TABLE::Load ( const wxString &  aFileName)
inherited

Load the library table using the path defined by aFileName aFallBackTable.

Parameters
aFileNamecontains the full path to the s-expression file.
Exceptions
IO_ERRORif an error occurs attempting to load the footprint library table.

Definition at line 329 of file lib_table_base.cpp.

331 {
332  // It's OK if footprint library tables are missing.
333  if( wxFileName::IsFileReadable( aFileName ) )
334  {
335  FILE_LINE_READER reader( aFileName );
336  LIB_TABLE_LEXER lexer( &reader );
337 
338  Parse( &lexer );
339  }
340 }
A LINE_READER that reads from an open file.
Definition: richio.h:172
virtual void Parse(LIB_TABLE_LEXER *aLexer)=0
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...

References LIB_TABLE::Parse().

Referenced by SYMBOL_LIB_TABLE::LoadGlobalTable(), LoadGlobalTable(), SCH_EDIT_FRAME::LoadSheetFromFile(), PROJECT::PcbFootprintLibs(), SCH::IFACE::SaveFileAs(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow(), and DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow().

◆ LoadGlobalTable()

bool FP_LIB_TABLE::LoadGlobalTable ( FP_LIB_TABLE aTable)
static

Load the global footprint library table into aTable.

This probably should be move into the application object when KiCad is changed to a single process application. This is the least painful solution for the time being.

Parameters
aTablethe FP_LIB_TABLE object to load.
Returns
true if the global library table exists and is loaded properly.
Exceptions
IO_ERRORif an error occurs attempting to load the footprint library table.

Definition at line 481 of file fp_lib_table.cpp.

482 {
483  bool tableExists = true;
484  wxFileName fn = GetGlobalTableFileName();
485 
486  if( !fn.FileExists() )
487  {
488  tableExists = false;
489 
490  if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) )
491  {
492  THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path \"%s\"." ),
493  fn.GetPath() ) );
494  }
495 
496  // Attempt to copy the default global file table from the KiCad
497  // template folder to the user's home configuration path.
498  SEARCH_STACK ss;
499 
500  SystemDirsAppend( &ss );
501 
502  wxString templatePath =
503  Pgm().GetLocalEnvVariables().at( wxT( "KICAD6_TEMPLATE_DIR" ) ).GetValue();
504 
505  if( !templatePath.IsEmpty() )
506  ss.AddPaths( templatePath, 0 );
507 
508  wxString fileName = ss.FindValidPath( global_tbl_name );
509 
510  // The fallback is to create an empty global footprint table for the user to populate.
511  if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
512  {
513  FP_LIB_TABLE emptyTable;
514 
515  emptyTable.Save( fn.GetFullPath() );
516  }
517  }
518 
519  aTable.Load( fn.GetFullPath() );
520 
521  return tableExists;
522 }
static const wxChar global_tbl_name[]
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:70
Look for files in a number of paths.
Definition: search_stack.h:41
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
#define _(s)
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Append system places to aSearchStack in a platform specific way and pertinent to KiCad programs.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
static wxString GetGlobalTableFileName()

References _, SEARCH_STACK::AddPaths(), SEARCH_STACK::FindValidPath(), Format(), GetGlobalTableFileName(), global_tbl_name, LIB_TABLE::Load(), Pgm(), LIB_TABLE::Save(), SystemDirsAppend(), and THROW_IO_ERROR.

Referenced by CV::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), and DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow().

◆ operator!=() [1/2]

bool FP_LIB_TABLE::operator!= ( const FP_LIB_TABLE r) const
inline

Definition at line 117 of file fp_lib_table.h.

117 { return !( *this == r ); }

◆ operator!=() [2/2]

bool LIB_TABLE::operator!= ( const LIB_TABLE r) const
inlineinherited

Definition at line 350 of file lib_table_base.h.

350 { return !( *this == r ); }

◆ operator==() [1/2]

bool FP_LIB_TABLE::operator== ( const FP_LIB_TABLE aFpTable) const

Definition at line 217 of file fp_lib_table.cpp.

218 {
219  if( rows.size() == aFpTable.rows.size() )
220  {
221  for( unsigned i = 0; i < rows.size(); ++i )
222  {
223  if( (FP_LIB_TABLE_ROW&)rows[i] != (FP_LIB_TABLE_ROW&)aFpTable.rows[i] )
224  return false;
225  }
226 
227  return true;
228  }
229 
230  return false;
231 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
LIB_TABLE_ROWS rows

References LIB_TABLE::rows.

◆ operator==() [2/2]

bool LIB_TABLE::operator== ( const LIB_TABLE r) const
inlineinherited

Compares this table against another.

This compares the row contents against each other. Any fallback tables are not checked.

Definition at line 334 of file lib_table_base.h.

335  {
336  if( rows.size() == r.rows.size() )
337  {
338  unsigned i;
339 
340  for( i = 0; i < rows.size() && rows[i] == r.rows[i]; ++i )
341  ;
342 
343  if( i == rows.size() )
344  return true;
345  }
346 
347  return false;
348  }
LIB_TABLE_ROWS rows

References LIB_TABLE::rows.

◆ Parse()

void FP_LIB_TABLE::Parse ( LIB_TABLE_LEXER *  aLexer)
overridevirtual

Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objects.

Parameters
aLexeris the lexer to parse.
Exceptions
IO_ERRORif an I/O error occurs during parsing.
PARSER_ERRORif the lexer format to parse is invalid.
boost::bad_pointerif an any attempt to add an invalid pointer to the boost::ptr_vector.
boost::bad_indexif an index outside the row table bounds is accessed.

Implements LIB_TABLE.

Definition at line 73 of file fp_lib_table.cpp.

74 {
75  T tok;
76  wxString errMsg; // to collect error messages
77 
78  // This table may be nested within a larger s-expression, or not.
79  // Allow for parser of that optional containing s-epression to have looked ahead.
80  if( in->CurTok() != T_fp_lib_table )
81  {
82  in->NeedLEFT();
83 
84  if( ( tok = in->NextTok() ) != T_fp_lib_table )
85  in->Expecting( T_fp_lib_table );
86  }
87 
88  while( ( tok = in->NextTok() ) != T_RIGHT )
89  {
90  std::unique_ptr<FP_LIB_TABLE_ROW> row = std::make_unique<FP_LIB_TABLE_ROW>();
91 
92  if( tok == T_EOF )
93  in->Expecting( T_RIGHT );
94 
95  if( tok != T_LEFT )
96  in->Expecting( T_LEFT );
97 
98  // in case there is a "row integrity" error, tell where later.
99  int lineNum = in->CurLineNumber();
100 
101  if( ( tok = in->NextTok() ) != T_lib )
102  in->Expecting( T_lib );
103 
104  // (name NICKNAME)
105  in->NeedLEFT();
106 
107  if( ( tok = in->NextTok() ) != T_name )
108  in->Expecting( T_name );
109 
110  in->NeedSYMBOLorNUMBER();
111 
112  row->SetNickName( in->FromUTF8() );
113 
114  in->NeedRIGHT();
115 
116  // After (name), remaining (lib) elements are order independent, and in
117  // some cases optional.
118  bool sawType = false;
119  bool sawOpts = false;
120  bool sawDesc = false;
121  bool sawUri = false;
122  bool sawDisabled = false;
123 
124  while( ( tok = in->NextTok() ) != T_RIGHT )
125  {
126  if( tok == T_EOF )
127  in->Unexpected( T_EOF );
128 
129  if( tok != T_LEFT )
130  in->Expecting( T_LEFT );
131 
132  tok = in->NeedSYMBOLorNUMBER();
133 
134  switch( tok )
135  {
136  case T_uri:
137  if( sawUri )
138  in->Duplicate( tok );
139  sawUri = true;
140  in->NeedSYMBOLorNUMBER();
141  row->SetFullURI( in->FromUTF8() );
142  break;
143 
144  case T_type:
145  if( sawType )
146  in->Duplicate( tok );
147  sawType = true;
148  in->NeedSYMBOLorNUMBER();
149  row->SetType( in->FromUTF8() );
150  break;
151 
152  case T_options:
153  if( sawOpts )
154  in->Duplicate( tok );
155  sawOpts = true;
156  in->NeedSYMBOLorNUMBER();
157  row->SetOptions( in->FromUTF8() );
158  break;
159 
160  case T_descr:
161  if( sawDesc )
162  in->Duplicate( tok );
163  sawDesc = true;
164  in->NeedSYMBOLorNUMBER();
165  row->SetDescr( in->FromUTF8() );
166  break;
167 
168  case T_disabled:
169  if( sawDisabled )
170  in->Duplicate( tok );
171  sawDisabled = true;
172  row->SetEnabled( false );
173  break;
174 
175  default:
176  in->Unexpected( tok );
177  }
178 
179  in->NeedRIGHT();
180  }
181 
182  if( !sawType )
183  in->Expecting( T_type );
184 
185  if( !sawUri )
186  in->Expecting( T_uri );
187 
188  // all nickNames within this table fragment must be unique, so we do not
189  // use doReplace in InsertRow(). (However a fallBack table can have a
190  // conflicting nickName and ours will supercede that one since in
191  // FindLib() we search this table before any fall back.)
192  wxString nickname = row->GetNickName(); // store it to be able to used it
193  // after row deletion if an error occurs
194  LIB_TABLE_ROW* tmp = row.release();
195 
196  if( !InsertRow( tmp ) )
197  {
198  delete tmp; // The table did not take ownership of the row.
199 
200  wxString msg = wxString::Format( _( "Duplicate library nickname \"%s\" found in "
201  "footprint library table file line %d" ),
202  nickname,
203  lineNum );
204 
205  if( !errMsg.IsEmpty() )
206  errMsg << '\n';
207 
208  errMsg << msg;
209  }
210  }
211 
212  if( !errMsg.IsEmpty() )
213  THROW_IO_ERROR( errMsg );
214 }
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), LIB_TABLE::InsertRow(), and THROW_IO_ERROR.

Referenced by FP_GRID_TRICKS::paste_text().

◆ ParseOptions()

PROPERTIES * LIB_TABLE::ParseOptions ( const std::string &  aOptionsList)
staticinherited

Parses aOptionsList and places the result into a PROPERTIES object which is returned.

If the options field is empty, then the returned PROPERTIES will be a NULL pointer.

Typically aOptionsList comes from the "options" field within a LIB_TABLE_ROW and the format is simply a comma separated list of name value pairs. e.g.: [name1[=value1][|name2[=value2]]] etc. When using the UI to create or edit a library table, this formatting is handled for you.

Definition at line 350 of file lib_table_base.cpp.

351 {
352  if( aOptionsList.size() )
353  {
354  const char* cp = &aOptionsList[0];
355  const char* end = cp + aOptionsList.size();
356 
357  PROPERTIES props;
358  std::string pair;
359 
360  // Parse all name=value pairs
361  while( cp < end )
362  {
363  pair.clear();
364 
365  // Skip leading white space.
366  while( cp < end && isspace( *cp ) )
367  ++cp;
368 
369  // Find the end of pair/field
370  while( cp < end )
371  {
372  if( *cp == '\\' && cp + 1 < end && cp[1] == OPT_SEP )
373  {
374  ++cp; // skip the escape
375  pair += *cp++; // add the separator
376  }
377  else if( *cp == OPT_SEP )
378  {
379  ++cp; // skip the separator
380  break; // process the pair
381  }
382  else
383  pair += *cp++;
384  }
385 
386  // stash the pair
387  if( pair.size() )
388  {
389  // first equals sign separates 'name' and 'value'.
390  size_t eqNdx = pair.find( '=' );
391 
392  if( eqNdx != pair.npos )
393  {
394  std::string name = pair.substr( 0, eqNdx );
395  std::string value = pair.substr( eqNdx + 1 );
396  props[name] = value;
397  }
398  else
399  props[pair] = ""; // property is present, but with no value.
400  }
401  }
402 
403  if( props.size() )
404  return new PROPERTIES( props );
405  }
406 
407  return nullptr;
408 }
std::vector< PROPERTY > PROPERTIES
Definition: specctra.h:182
A name/value tuple with unique names and optional values.
Definition: properties.h:33
const char * name
Definition: DXF_plotter.cpp:59
#define OPT_SEP
options separator character

References name, and OPT_SEP.

Referenced by LIB_TABLE_ROW::SetOptions(), and DIALOG_FP_PLUGIN_OPTIONS::TransferDataToWindow().

◆ PrefetchLib()

void FP_LIB_TABLE::PrefetchLib ( const wxString &  aNickname)

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.

Parameters
aNicknameis a locator for the library; it is a name in LIB_TABLE_ROW.
Exceptions
IO_ERRORif there is an error prefetching the library.

Definition at line 283 of file fp_lib_table.cpp.

284 {
285  const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
286  wxASSERT( (PLUGIN*) row->plugin );
287  row->plugin->PrefetchLib( row->GetFullURI( true ), row->GetProperties() );
288 }
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:40
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

References FindRow(), LIB_TABLE_ROW::GetFullURI(), LIB_TABLE_ROW::GetProperties(), and FP_LIB_TABLE_ROW::plugin.

Referenced by FOOTPRINT_LIST_IMPL::loader_job().

◆ reindex()

void LIB_TABLE::reindex ( )
inlineprotectedinherited

Definition at line 505 of file lib_table_base.h.

506  {
507  std::lock_guard<std::recursive_mutex> lock( m_nickIndexMutex );
508 
509  nickIndex.clear();
510 
511  for( LIB_TABLE_ROWS_ITER it = rows.begin(); it != rows.end(); ++it )
512  nickIndex.insert( INDEX_VALUE( it->GetNickName(), it - rows.begin() ) );
513  }
LIB_TABLE_ROWS rows
INDEX::value_type INDEX_VALUE
LIB_TABLE_ROWS::iterator LIB_TABLE_ROWS_ITER
std::recursive_mutex m_nickIndexMutex
Mutex to protect access to the nickIndex variable.
INDEX nickIndex
this particular key is the nickName within each row.

References LIB_TABLE::m_nickIndexMutex, LIB_TABLE::nickIndex, and LIB_TABLE::rows.

Referenced by LIB_TABLE::ensureIndex(), PANEL_FP_LIB_TABLE::TransferDataFromWindow(), and PANEL_SYM_LIB_TABLE::TransferDataFromWindow().

◆ RemoveRow()

bool LIB_TABLE::RemoveRow ( LIB_TABLE_ROW aRow)
inlineinherited

Removes a row from the table.

Parameters
aRowis the row to remove
Returns
true if the row was found (and removed)

Definition at line 432 of file lib_table_base.h.

433  {
434  for( auto iter = rows.begin(); iter != rows.end(); ++iter )
435  {
436  if( *iter == *aRow )
437  {
438  rows.erase( iter, iter + 1 );
439  return true;
440  }
441  }
442  return false;
443  }
LIB_TABLE_ROWS rows

References LIB_TABLE::rows.

Referenced by SYMBOL_LIBRARY_MANAGER::addLibrary().

◆ Save()

void LIB_TABLE::Save ( const wxString &  aFileName) const
inherited

Write this library table to aFileName in s-expression form.

Parameters
aFileNameis the name of the file to write to.

Definition at line 343 of file lib_table_base.cpp.

344 {
345  FILE_OUTPUTFORMATTER sf( aFileName );
346  Format( &sf, 0 );
347 }
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const =0
Generate the table in s-expression format to aOutput with an indention level of aIndentLevel.
Used for text file output.
Definition: richio.h:453

References LIB_TABLE::Format().

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), LoadGlobalTable(), PCB_EDIT_FRAME::OpenProjectFiles(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), SCH::IFACE::SaveFileAs(), SCH_BASE_FRAME::saveSymbolLibTables(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow(), and DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow().

◆ Type()

KICAD_T FP_LIB_TABLE::Type ( )
inlineoverridevirtual

Implements PROJECT::_ELEM.

Definition at line 99 of file fp_lib_table.h.

99 { return FP_LIB_TABLE_T; }

References FP_LIB_TABLE_T.

Referenced by PROJECT::PcbFootprintLibs().

Friends And Related Function Documentation

◆ FP_LIB_TABLE_GRID

friend class FP_LIB_TABLE_GRID
friend

Definition at line 291 of file fp_lib_table.h.

Member Data Documentation

◆ fallBack

LIB_TABLE* LIB_TABLE::fallBack
protectedinherited

◆ m_nickIndexMutex

std::recursive_mutex LIB_TABLE::m_nickIndexMutex
mutableprotectedinherited

Mutex to protect access to the nickIndex variable.

Definition at line 545 of file lib_table_base.h.

Referenced by LIB_TABLE::Clear(), LIB_TABLE::ensureIndex(), LIB_TABLE::findRow(), LIB_TABLE::InsertRow(), and LIB_TABLE::reindex().

◆ nickIndex

INDEX LIB_TABLE::nickIndex
protectedinherited

this particular key is the nickName within each row.

Definition at line 540 of file lib_table_base.h.

Referenced by LIB_TABLE::Clear(), LIB_TABLE::ensureIndex(), LIB_TABLE::findRow(), LIB_TABLE::InsertRow(), and LIB_TABLE::reindex().

◆ rows


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