KiCad PCB EDA Suite
Loading...
Searching...
No Matches
DESIGN_BLOCK_LIB_TABLE Class Reference

#include <design_block_lib_table.h>

Inheritance diagram for DESIGN_BLOCK_LIB_TABLE:
LIB_TABLE PROJECT::_ELEM DESIGN_BLOCK_LIB_TABLE_GRID

Public Types

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

Public Member Functions

PROJECT::ELEM ProjectElementType () 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.
 
virtual void Format (OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
 Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
 
 DESIGN_BLOCK_LIB_TABLE (DESIGN_BLOCK_LIB_TABLE *aFallBackTable=nullptr)
 Build a design block library table by pre-pending this table fragment in front of aFallBackTable.
 
bool operator== (const DESIGN_BLOCK_LIB_TABLE &aFpTable) const
 
bool operator!= (const DESIGN_BLOCK_LIB_TABLE &r) const
 
const DESIGN_BLOCK_LIB_TABLE_ROWFindRow (const wxString &aNickName, bool aCheckIfEnabled=false)
 Return an DESIGN_BLOCK_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table fragment.
 
void DesignBlockEnumerate (wxArrayString &aDesignBlockNames, const wxString &aNickname, bool aBestEfforts)
 Return a list of design block names contained within the library given by aNickname.
 
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.
 
void PrefetchLib (const wxString &aNickname)
 If possible, prefetches the specified library (e.g.
 
DESIGN_BLOCKDesignBlockLoad (const wxString &aNickname, const wxString &aDesignBlockName, bool aKeepUUID=false)
 Load a design block having aDesignBlockName from the library given by aNickname.
 
bool DesignBlockExists (const wxString &aNickname, const wxString &aDesignBlockName)
 Indicates whether or not the given design block already exists in the given library.
 
const DESIGN_BLOCKGetEnumeratedDesignBlock (const wxString &aNickname, const wxString &aDesignBlockName)
 A version of DesignBlockLoad() for use after DesignBlockEnumerate() for more efficient cache management.
 
SAVE_T DesignBlockSave (const wxString &aNickname, const DESIGN_BLOCK *aDesignBlock, bool aOverwrite=true)
 Write aDesignBlock to an existing library given by aNickname.
 
void DesignBlockDelete (const wxString &aNickname, const wxString &aDesignBlockName)
 Delete the aDesignBlockName from the library given by aNickname.
 
bool IsDesignBlockLibWritable (const wxString &aNickname)
 Return true if the library given by aNickname is writable.
 
void DesignBlockLibDelete (const wxString &aNickname)
 
void DesignBlockLibCreate (const wxString &aNickname)
 
DESIGN_BLOCKDesignBlockLoadWithOptionalNickname (const LIB_ID &aDesignBlockId, bool aKeepUUID=false)
 Load a design block having aDesignBlockId with possibly an empty nickname.
 
bool operator== (const LIB_TABLE &r) const
 Compares this table against another.
 
bool operator!= (const LIB_TABLE &r) const
 
unsigned GetCount () const
 Get the number of rows contained in the table.
 
LIB_TABLE_ROWAt (unsigned aIndex)
 Get the 'n'th LIB_TABLE_ROW object.
 
const LIB_TABLE_ROWAt (unsigned aIndex) const
 Get the 'n'th LIB_TABLE_ROW object.
 
bool IsEmpty (bool aIncludeFallback=true)
 Return true if the table is empty.
 
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.
 
bool HasLibraryWithPath (const wxString &aPath) const
 Test for the existence of aPath in the library table.
 
std::vector< wxString > GetLogicalLibs ()
 Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
 
wxString GetFullURI (const wxString &aLibNickname, bool aExpandEnvVars=true) const
 Return the full URI of the library mapped to aLibNickname.
 
bool InsertRow (LIB_TABLE_ROW *aRow, bool doReplace=false)
 Adds aRow if it does not already exist or if doReplace is true.
 
bool RemoveRow (const LIB_TABLE_ROW *aRow)
 Removes a row from the table and frees the pointer.
 
bool ReplaceRow (size_t aIndex, LIB_TABLE_ROW *aRow)
 Replaces the Nth row with the given new row.
 
bool ChangeRowOrder (size_t aIndex, int aOffset)
 Moves a row within the table.
 
void TransferRows (LIB_TABLE_ROWS &aRowsList)
 Takes ownership of another list of rows; the original list will be freed.
 
const LIB_TABLE_ROWFindRowByURI (const wxString &aURI)
 
void Load (const wxString &aFileName)
 Load the library table using the path defined by aFileName aFallBackTable.
 
void Save (const wxString &aFileName) const
 Write this library table to aFileName in s-expression form.
 
int GetVersion () const
 Returns the version number (0 if unset)
 

Static Public Member Functions

static bool LoadGlobalTable (DESIGN_BLOCK_LIB_TABLE &aTable)
 Load the global design block library table into aTable.
 
static DESIGN_BLOCK_LIB_TABLEGetGlobalLibTable ()
 
static DESIGN_BLOCK_LIST_IMPLGetGlobalList ()
 
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 design block libraries.
 
static std::map< std::string, UTF8 > * ParseOptions (const std::string &aOptionsList)
 Parses aOptionsList and places the result into a #PROPERTIES object which is returned.
 
static UTF8 FormatOptions (const std::map< std::string, UTF8 > *aProperties)
 Returns a list of options from the aProperties parameter.
 

Protected Member Functions

void clear ()
 
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.
 
bool doInsertRow (LIB_TABLE_ROW *aRow, bool doReplace=false)
 Performs the mechanics of inserting a row, but without locking or reindexing.
 
bool migrate ()
 Updates the env vars from older version of KiCad, provided they do not currently resolve to anything.
 
void reindex ()
 

Protected Attributes

std::unique_ptr< LIB_TABLE_IOm_io
 
LIB_TABLEm_fallBack
 
int m_version
 Versioning to handle importing old tables.
 
LIB_TABLE_ROWS m_rows
 Owning set of rows.
 
std::map< wxString, LIB_TABLE_ROWS_ITERm_rowsMap
 this is a non-owning index into the LIB_TABLE_ROWS table
 
std::shared_mutex m_mutex
 Mutex to protect access to the rows vector.
 

Friends

class DESIGN_BLOCK_LIB_TABLE_GRID
 

Detailed Description

Definition at line 89 of file design_block_lib_table.h.

Member Enumeration Documentation

◆ SAVE_T

The set of return values from DesignBlockSave() below.

Enumerator
SAVE_OK 
SAVE_SKIPPED 

Definition at line 192 of file design_block_lib_table.h.

Constructor & Destructor Documentation

◆ DESIGN_BLOCK_LIB_TABLE()

DESIGN_BLOCK_LIB_TABLE::DESIGN_BLOCK_LIB_TABLE ( DESIGN_BLOCK_LIB_TABLE aFallBackTable = nullptr)

Build a design block 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 DESIGN_BLOCK_LIB_TABLE which is searched only when a row is not found in this table. No ownership is taken of aFallBackTable.

Definition at line 78 of file design_block_lib_table.cpp.

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 435 of file lib_table_base.h.

Referenced by LoadGlobalTable(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), DESIGN_BLOCK_GRID_TRICKS::paste_text(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), and PCB::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 443 of file lib_table_base.h.

◆ ChangeRowOrder()

bool LIB_TABLE::ChangeRowOrder ( size_t  aIndex,
int  aOffset 
)
inherited

Moves a row within the table.

Parameters
aIndexis the current index of the row to move
aOffsetis the number of positions to move it by in the table
Returns
true if the move resulted in a change

Definition at line 435 of file lib_table_base.cpp.

References LIB_TABLE::m_mutex, LIB_TABLE::m_rows, and LIB_TABLE::reindex().

Referenced by PANEL_SYM_LIB_TABLE::moveDownHandler(), and PANEL_SYM_LIB_TABLE::moveUpHandler().

◆ clear()

void LIB_TABLE::clear ( )
protectedinherited

◆ DesignBlockDelete()

void DESIGN_BLOCK_LIB_TABLE::DesignBlockDelete ( const wxString &  aNickname,
const wxString &  aDesignBlockName 
)

Delete the aDesignBlockName from the library given by aNickname.

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

Definition at line 447 of file design_block_lib_table.cpp.

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

Referenced by SCH_EDIT_FRAME::DeleteDesignBlockFromLibrary(), and SCH_EDIT_FRAME::EditDesignBlockProperties().

◆ DesignBlockEnumerate()

void DESIGN_BLOCK_LIB_TABLE::DesignBlockEnumerate ( wxArrayString &  aDesignBlockNames,
const wxString &  aNickname,
bool  aBestEfforts 
)

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

Parameters
aDesignBlockNamesis the list to fill with the design block 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 design block cannot be loaded.

Definition at line 312 of file design_block_lib_table.cpp.

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

Referenced by DESIGN_BLOCK_LIST_IMPL::loadDesignBlocks().

◆ DesignBlockExists()

bool DESIGN_BLOCK_LIB_TABLE::DesignBlockExists ( const wxString &  aNickname,
const wxString &  aDesignBlockName 
)

Indicates whether or not the given design block already exists in the given library.

Definition at line 386 of file design_block_lib_table.cpp.

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

◆ DesignBlockLibCreate()

void DESIGN_BLOCK_LIB_TABLE::DesignBlockLibCreate ( const wxString &  aNickname)

◆ DesignBlockLibDelete()

void DESIGN_BLOCK_LIB_TABLE::DesignBlockLibDelete ( const wxString &  aNickname)

◆ DesignBlockLoad()

DESIGN_BLOCK * DESIGN_BLOCK_LIB_TABLE::DesignBlockLoad ( const wxString &  aNickname,
const wxString &  aDesignBlockName,
bool  aKeepUUID = false 
)

Load a design block having aDesignBlockName from the library given by aNickname.

Parameters
aNicknameis a locator for the "library", it is a "name" in LIB_TABLE_ROW.
aDesignBlockNameis the name of the design block to load.
aKeepUUID= true to keep initial items UUID, false to set new UUID normally true if loaded in the design block editor, false if loaded in the board editor. Used only in kicad_plugin
Returns
the design block 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 aDesignBlockName cannot be found.

Definition at line 404 of file design_block_lib_table.cpp.

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

Referenced by DesignBlockLoadWithOptionalNickname().

◆ DesignBlockLoadWithOptionalNickname()

DESIGN_BLOCK * DESIGN_BLOCK_LIB_TABLE::DesignBlockLoadWithOptionalNickname ( const LIB_ID aDesignBlockId,
bool  aKeepUUID = false 
)

Load a design block having aDesignBlockId with possibly an empty nickname.

Parameters
aDesignBlockIdthe [nickname] and name of the design block to load.
aKeepUUID= true to keep initial items UUID, false to set new UUID normally true if loaded in the design block editor, false if loaded in the board editor used only in kicad_plugin
Returns
the DESIGN_BLOCK 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 aDesignBlockName cannot be found.
PARSE_ERRORif aDesignBlockId is not parsed OK.

Definition at line 483 of file design_block_lib_table.cpp.

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

Referenced by SchGetDesignBlock().

◆ DesignBlockSave()

DESIGN_BLOCK_LIB_TABLE::SAVE_T DESIGN_BLOCK_LIB_TABLE::DesignBlockSave ( const wxString &  aNickname,
const DESIGN_BLOCK aDesignBlock,
bool  aOverwrite = true 
)

Write aDesignBlock to an existing library given by aNickname.

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

Parameters
aNicknameis a locator for the "library", it is a "name" in LIB_TABLE_ROW.
aDesignBlockis what to store in the library. The caller continues to own the design block after this call.
aOverwritewhen true means overwrite any existing design block 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 421 of file design_block_lib_table.cpp.

References FindRow(), LIB_TABLE_ROW::GetFullURI(), DESIGN_BLOCK::GetLibId(), LIB_ID::GetLibItemName(), LIB_TABLE_ROW::GetProperties(), DESIGN_BLOCK_LIB_TABLE_ROW::plugin, SAVE_OK, and SAVE_SKIPPED.

Referenced by SCH_EDIT_FRAME::EditDesignBlockProperties(), SCH_EDIT_FRAME::SaveSelectionAsDesignBlock(), and SCH_EDIT_FRAME::SaveSheetAsDesignBlock().

◆ doInsertRow()

bool LIB_TABLE::doInsertRow ( LIB_TABLE_ROW aRow,
bool  doReplace = false 
)
protectedinherited

Performs the mechanics of inserting a row, but without locking or reindexing.

Definition at line 361 of file lib_table_base.cpp.

References LIB_TABLE_ROW::GetNickName(), LIB_TABLE::m_rows, LIB_TABLE::m_rowsMap, LIB_TABLE::reindex(), and LIB_TABLE_ROW::SetParent().

Referenced by LIB_TABLE::InsertRow(), SYMBOL_LIB_TABLE::Parse(), Parse(), and FP_LIB_TABLE::Parse().

◆ FindRow()

const DESIGN_BLOCK_LIB_TABLE_ROW * DESIGN_BLOCK_LIB_TABLE::FindRow ( const wxString &  aNickName,
bool  aCheckIfEnabled = false 
)

Return an DESIGN_BLOCK_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 DESIGN_BLOCK_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 330 of file design_block_lib_table.cpp.

References _, DESIGN_BLOCK_IO_MGR::FindPlugin(), LIB_TABLE::findRow(), DESIGN_BLOCK_LIB_TABLE_ROW::plugin, DESIGN_BLOCK_LIB_TABLE_ROW::setPlugin(), THROW_IO_ERROR, and DESIGN_BLOCK_LIB_TABLE_ROW::type.

Referenced by DESIGN_BLOCK_TREE_MODEL_ADAPTER::AddLibraries(), DesignBlockDelete(), DesignBlockEnumerate(), DesignBlockExists(), DesignBlockLibCreate(), DesignBlockLibDelete(), DesignBlockLoad(), DesignBlockSave(), GenerateTimestamp(), GetEnumeratedDesignBlock(), IsDesignBlockLibWritable(), LoadGlobalTable(), and PrefetchLib().

◆ 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 250 of file lib_table_base.cpp.

References LIB_TABLE_ROW::GetIsEnabled(), LIB_TABLE::m_fallBack, LIB_TABLE::m_mutex, and LIB_TABLE::m_rowsMap.

Referenced by SYMBOL_LIB_TABLE::FindRow(), FindRow(), FP_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 293 of file lib_table_base.cpp.

References LIB_TABLE::m_fallBack, LIB_TABLE::m_io, and LIB_TABLE::m_rows.

Referenced by PCB_EDIT_FRAME::ExportFootprintsToLibrary(), SYMBOL_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), and DIALOG_SYMBOL_REMAP::remapSymbolToLibTable().

◆ Format()

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

Generate the table in s-expression format to aOutput with an indentation 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 263 of file design_block_lib_table.cpp.

References LIB_TABLE::m_rows, LIB_TABLE::m_version, and OUTPUTFORMATTER::Print().

◆ FormatOptions()

UTF8 LIB_TABLE::FormatOptions ( const std::map< std::string, UTF8 > *  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 606 of file lib_table_base.cpp.

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

Referenced by DIALOG_PLUGIN_OPTIONS::TransferDataFromWindow().

◆ GenerateTimestamp()

long long DESIGN_BLOCK_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 275 of file design_block_lib_table.cpp.

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

Referenced by DESIGN_BLOCK_LIST_IMPL::ReadDesignBlockFiles().

◆ GetCount()

◆ 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 202 of file lib_table_base.cpp.

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

Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_TREE_MODEL_ADAPTER::AddLibrary(), SAVE_AS_DIALOG::SAVE_AS_DIALOG(), and PCB_BASE_FRAME::SelectLibrary().

◆ GetEnumeratedDesignBlock()

const DESIGN_BLOCK * DESIGN_BLOCK_LIB_TABLE::GetEnumeratedDesignBlock ( const wxString &  aNickname,
const wxString &  aDesignBlockName 
)

A version of DesignBlockLoad() for use after DesignBlockEnumerate() for more efficient cache management.

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

Definition at line 375 of file design_block_lib_table.cpp.

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

Referenced by DESIGN_BLOCK_TREE_MODEL_ADAPTER::GenerateInfo(), and DESIGN_BLOCK_INFO_IMPL::load().

◆ GetFullURI()

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

◆ GetGlobalLibTable()

◆ GetGlobalList()

◆ GetGlobalTableFileName()

◆ GetLogicalLibs()

◆ GetVersion()

int LIB_TABLE::GetVersion ( ) const
inlineinherited

Returns the version number (0 if unset)

Returns
integer version number read from table

Definition at line 585 of file lib_table_base.h.

◆ GlobalPathEnvVariableName()

const wxString DESIGN_BLOCK_LIB_TABLE::GlobalPathEnvVariableName ( )
static

Return the name of the environment variable used to hold the directory of locally installed "KiCad sponsored" system design block 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 515 of file design_block_lib_table.cpp.

References ENV_VAR::GetVersionedEnvVarName().

Referenced by PANEL_DESIGN_BLOCK_LIB_TABLE::populateEnvironReadOnlyTable().

◆ HasLibrary()

◆ HasLibraryWithPath()

bool LIB_TABLE::HasLibraryWithPath ( const wxString &  aPath) const
inherited

Test for the existence of aPath 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 225 of file lib_table_base.cpp.

References LIB_TABLE::m_rows.

Referenced by PCM_DESIGN_BLOCK_LIB_TRAVERSER::OnDir(), PCM_FP_LIB_TRAVERSER::OnDir(), and PCM_SYM_LIB_TRAVERSER::OnFile().

◆ 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 350 of file lib_table_base.cpp.

References LIB_TABLE::doInsertRow(), LIB_TABLE::m_mutex, and LIB_TABLE::reindex().

Referenced by SCH_EDIT_FRAME::AddDesignBlockLibrary(), SYMBOL_LIBRARY_MANAGER::addLibrary(), PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), SCH_IO_ALTIUM::LoadSchematicFile(), SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), SCH_IO_EAGLE::LoadSchematicFile(), SCH_IO_EASYEDAPRO::LoadSchematicFile(), SCH_EDIT_FRAME::LoadSheetFromFile(), PCM_DESIGN_BLOCK_LIB_TRAVERSER::OnDir(), PCM_FP_LIB_TRAVERSER::OnDir(), PCM_SYM_LIB_TRAVERSER::OnFile(), PCB_EDIT_FRAME::OpenProjectFiles(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

◆ IsDesignBlockLibWritable()

bool DESIGN_BLOCK_LIB_TABLE::IsDesignBlockLibWritable ( 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 458 of file design_block_lib_table.cpp.

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

◆ 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 193 of file lib_table_base.cpp.

References LIB_TABLE::IsEmpty(), LIB_TABLE::m_fallBack, and LIB_TABLE::m_rows.

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

◆ Load()

◆ LoadGlobalTable()

bool DESIGN_BLOCK_LIB_TABLE::LoadGlobalTable ( DESIGN_BLOCK_LIB_TABLE aTable)
static

Load the global design block 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 DESIGN_BLOCK_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 design block library table.

Definition at line 585 of file design_block_lib_table.cpp.

References _, SEARCH_STACK::AddPaths(), LIB_TABLE::At(), LIB_TABLE::clear(), FindRow(), SETTINGS_MANAGER::GetAppSettings(), LIB_TABLE::GetCount(), LIB_TABLE_ROW::GetFullURI(), GetGlobalTableFileName(), PGM_BASE::GetLocalEnvVariables(), LIB_TABLE_ROW::GetNickName(), PGM_BASE::GetSettingsManager(), ENV_VAR::GetVersionedEnvVarValue(), global_tbl_name, LIB_TABLE::Load(), KICAD_SETTINGS::m_PcmLibAutoAdd, KICAD_SETTINGS::m_PcmLibAutoRemove, KICAD_SETTINGS::m_PcmLibPrefix, path, Pgm(), LIB_TABLE::RemoveRow(), LIB_TABLE::Save(), SystemDirsAppend(), and THROW_IO_ERROR.

Referenced by SCH::IFACE::loadGlobalDesignBlockLibTable(), and DIALOG_GLOBAL_DESIGN_BLOCK_LIB_TABLE_CONFIG::TransferDataFromWindow().

◆ migrate()

bool LIB_TABLE::migrate ( )
protectedinherited

Updates the env vars from older version of KiCad, provided they do not currently resolve to anything.

Returns
True if the tables were modified

Definition at line 479 of file lib_table_base.cpp.

References LIB_TABLE::m_rows.

Referenced by LIB_TABLE::Load().

◆ operator!=() [1/2]

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

Definition at line 110 of file design_block_lib_table.h.

◆ operator!=() [2/2]

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

Definition at line 420 of file lib_table_base.h.

◆ operator==() [1/2]

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

Definition at line 245 of file design_block_lib_table.cpp.

References LIB_TABLE::m_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 404 of file lib_table_base.h.

References LIB_TABLE::m_rows.

◆ Parse()

void DESIGN_BLOCK_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 86 of file design_block_lib_table.cpp.

References _, LIB_TABLE::doInsertRow(), LIB_TABLE::m_version, and THROW_IO_ERROR.

Referenced by DESIGN_BLOCK_GRID_TRICKS::paste_text().

◆ ParseOptions()

std::map< std::string, UTF8 > * 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 541 of file lib_table_base.cpp.

References name, and OPT_SEP.

Referenced by PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries(), PANEL_DESIGN_BLOCK_LIB_TABLE::onMigrateLibraries(), PANEL_FP_LIB_TABLE::onMigrateLibraries(), LIB_TABLE_ROW::SetOptions(), and DIALOG_PLUGIN_OPTIONS::TransferDataToWindow().

◆ PrefetchLib()

void DESIGN_BLOCK_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 322 of file design_block_lib_table.cpp.

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

Referenced by DESIGN_BLOCK_LIST_IMPL::loadLibs().

◆ ProjectElementType()

PROJECT::ELEM DESIGN_BLOCK_LIB_TABLE::ProjectElementType ( )
inlineoverridevirtual

Implements PROJECT::_ELEM.

Definition at line 92 of file design_block_lib_table.h.

References PROJECT::DESIGN_BLOCK_LIB_TABLE.

Referenced by PROJECT::DesignBlockLibs().

◆ reindex()

◆ RemoveRow()

bool LIB_TABLE::RemoveRow ( const LIB_TABLE_ROW aRow)
inherited

Removes a row from the table and frees the pointer.

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

Definition at line 383 of file lib_table_base.cpp.

References LIB_TABLE_ROW::GetNickName(), LIB_TABLE::m_mutex, LIB_TABLE::m_rows, LIB_TABLE::m_rowsMap, and LIB_TABLE::reindex().

Referenced by SYMBOL_LIBRARY_MANAGER::addLibrary(), LoadGlobalTable(), FP_LIB_TABLE::LoadGlobalTable(), and SYMBOL_LIB_TABLE::LoadGlobalTable().

◆ ReplaceRow()

bool LIB_TABLE::ReplaceRow ( size_t  aIndex,
LIB_TABLE_ROW aRow 
)
inherited

Replaces the Nth row with the given new row.

Returns
true if successful

Definition at line 420 of file lib_table_base.cpp.

References LIB_TABLE::m_mutex, LIB_TABLE::m_rows, LIB_TABLE::m_rowsMap, and LIB_TABLE::reindex().

Referenced by SYMBOL_GRID_TRICKS::paste_text().

◆ Save()

◆ TransferRows()

void LIB_TABLE::TransferRows ( LIB_TABLE_ROWS aRowsList)
inherited

Friends And Related Function Documentation

◆ DESIGN_BLOCK_LIB_TABLE_GRID

friend class DESIGN_BLOCK_LIB_TABLE_GRID
friend

Definition at line 289 of file design_block_lib_table.h.

Member Data Documentation

◆ m_fallBack

LIB_TABLE* LIB_TABLE::m_fallBack
protectedinherited

◆ m_io

std::unique_ptr<LIB_TABLE_IO> LIB_TABLE::m_io
protectedinherited

◆ m_mutex

std::shared_mutex LIB_TABLE::m_mutex
mutableprotectedinherited

◆ m_rows

LIB_TABLE_ROWS LIB_TABLE::m_rows
protectedinherited

Owning set of rows.

Definition at line 636 of file lib_table_base.h.

Referenced by DESIGN_BLOCK_LIB_TABLE_GRID::at(), SYMBOL_LIB_TABLE_GRID::at(), FP_LIB_TABLE_GRID::at(), DESIGN_BLOCK_LIB_TABLE_GRID::begin(), SYMBOL_LIB_TABLE_GRID::begin(), FP_LIB_TABLE_GRID::begin(), LIB_TABLE::ChangeRowOrder(), LIB_TABLE::clear(), DESIGN_BLOCK_LIB_TABLE_GRID::DESIGN_BLOCK_LIB_TABLE_GRID(), LIB_TABLE::doInsertRow(), DESIGN_BLOCK_LIB_TABLE_GRID::erase(), SYMBOL_LIB_TABLE_GRID::erase(), FP_LIB_TABLE_GRID::erase(), LIB_TABLE::FindRowByURI(), SYMBOL_LIB_TABLE::Format(), Format(), FP_LIB_TABLE::Format(), FP_LIB_TABLE_GRID::FP_LIB_TABLE_GRID(), LIB_TABLE::GetLogicalLibs(), LIB_TABLE::HasLibraryWithPath(), DESIGN_BLOCK_LIB_TABLE_GRID::insert(), SYMBOL_LIB_TABLE_GRID::insert(), FP_LIB_TABLE_GRID::insert(), LIB_TABLE::IsEmpty(), LIB_TABLE::migrate(), PANEL_DESIGN_BLOCK_LIB_TABLE::moveDownHandler(), PANEL_SYM_LIB_TABLE::moveDownHandler(), PANEL_FP_LIB_TABLE::moveDownHandler(), PANEL_DESIGN_BLOCK_LIB_TABLE::moveUpHandler(), PANEL_FP_LIB_TABLE::moveUpHandler(), operator==(), FP_LIB_TABLE::operator==(), LIB_TABLE::operator==(), SYMBOL_LIB_TABLE::operator==(), DESIGN_BLOCK_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), DESIGN_BLOCK_LIB_TABLE_GRID::push_back(), SYMBOL_LIB_TABLE_GRID::push_back(), FP_LIB_TABLE_GRID::push_back(), LIB_TABLE::reindex(), LIB_TABLE::RemoveRow(), LIB_TABLE::ReplaceRow(), DESIGN_BLOCK_LIB_TABLE_GRID::size(), SYMBOL_LIB_TABLE_GRID::size(), FP_LIB_TABLE_GRID::size(), SYMBOL_LIB_TABLE_GRID::SYMBOL_LIB_TABLE_GRID(), and LIB_TABLE::TransferRows().

◆ m_rowsMap

std::map<wxString, LIB_TABLE_ROWS_ITER> LIB_TABLE::m_rowsMap
protectedinherited

this is a non-owning index into the LIB_TABLE_ROWS table

Definition at line 639 of file lib_table_base.h.

Referenced by LIB_TABLE::clear(), LIB_TABLE::doInsertRow(), LIB_TABLE::findRow(), LIB_TABLE::reindex(), LIB_TABLE::RemoveRow(), and LIB_TABLE::ReplaceRow().

◆ m_version

int LIB_TABLE::m_version
mutableprotectedinherited

Versioning to handle importing old tables.

Definition at line 631 of file lib_table_base.h.

Referenced by SYMBOL_LIB_TABLE::Format(), Format(), FP_LIB_TABLE::Format(), LIB_TABLE::Load(), SYMBOL_LIB_TABLE::Parse(), Parse(), FP_LIB_TABLE::Parse(), and LIB_TABLE::Save().


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