KiCad PCB EDA Suite
|
A concrete implementation of LIB_TABLE that implements the minimum interface for testing. More...
Public Member Functions | |
TEST_LIB_TABLE (LIB_TABLE *aFallback=nullptr) | |
KICAD_T | Type () override |
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_ROW & | At (unsigned aIndex) |
Get the 'n'th LIB_TABLE_ROW object. More... | |
const LIB_TABLE_ROW & | At (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... | |
bool | HasLibraryWithPath (const wxString &aPath) const |
Test for the existence of aPath 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 (const LIB_TABLE_ROW *aRow) |
Removes a row from the table. More... | |
const LIB_TABLE_ROW * | FindRowByURI (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... | |
int | GetVersion () const |
Returns the version number (0 if unset) More... | |
Static Public Member Functions | |
static STRING_UTF8_MAP * | ParseOptions (const std::string &aOptionsList) |
Parses aOptionsList and places the result into a #PROPERTIES object which is returned. More... | |
static UTF8 | FormatOptions (const STRING_UTF8_MAP *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_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, else NULL. More... | |
bool | migrate () |
Updates the env vars from older version of KiCad, provided they do not currently resolve to anything. More... | |
void | reindex (bool aForce) |
Rebuilds the m_nickIndex. More... | |
void | ensureIndex () |
Protected Attributes | |
LIB_TABLE_ROWS | m_rows |
INDEX | m_nickIndex |
this particular key is the nickName within each row. More... | |
LIB_TABLE * | m_fallBack |
int | m_version |
Versioning to handle importing old tables. More... | |
std::shared_mutex | m_nickIndexMutex |
Mutex to protect access to the nickIndex variable. More... | |
Private Member Functions | |
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... | |
void | Format (OUTPUTFORMATTER *aOutput, int aIndentLevel) const override |
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel. More... | |
A concrete implementation of LIB_TABLE that implements the minimum interface for testing.
Notably, the Parse/Format functions are not used, as there is no "real" format to read/write.
Definition at line 79 of file test_lib_table.cpp.
|
protectedinherited |
this is a non-owning index into the LIB_TABLE_ROWS table
Definition at line 589 of file lib_table_base.h.
|
protectedinherited |
Definition at line 591 of file lib_table_base.h.
|
protectedinherited |
Definition at line 590 of file lib_table_base.h.
|
protectedinherited |
Definition at line 592 of file lib_table_base.h.
|
inline |
Definition at line 82 of file test_lib_table.cpp.
|
inlineinherited |
Get the 'n'th LIB_TABLE_ROW object.
aIndex | index of row (must exist: from 0 to GetCount() - 1) |
Definition at line 383 of file lib_table_base.h.
References LIB_TABLE::m_rows.
Referenced by FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), and PCB::IFACE::SaveFileAs().
|
inlineinherited |
Get the 'n'th LIB_TABLE_ROW object.
aIndex | index of row (must exist: from 0 to GetCount() - 1) |
Definition at line 391 of file lib_table_base.h.
References LIB_TABLE::m_rows.
|
inlineinherited |
Delete all rows.
Definition at line 338 of file lib_table_base.h.
References LIB_TABLE::m_nickIndex, LIB_TABLE::m_nickIndexMutex, and LIB_TABLE::m_rows.
Referenced by FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), PANEL_SYM_LIB_TABLE::TransferDataFromWindow(), and PANEL_FP_LIB_TABLE::TransferDataFromWindow().
|
inlineprotectedinherited |
Definition at line 572 of file lib_table_base.h.
References LIB_TABLE::m_nickIndex, and LIB_TABLE::reindex().
Referenced by LIB_TABLE::findRow(), LIB_TABLE::FindRowByURI(), and LIB_TABLE::InsertRow().
|
protectedinherited |
Return a LIB_TABLE_ROW if aNickname is found in this table or in any chained fallBack table fragment, else NULL.
aNickname | is the name of the library table entry to find. |
aCheckIfEnabled | is a flag to check if the library table entry is enabled. |
Definition at line 187 of file lib_table_base.cpp.
References LIB_TABLE::ensureIndex(), LIB_TABLE_ROW::GetIsEnabled(), LIB_TABLE::m_fallBack, LIB_TABLE::m_nickIndex, LIB_TABLE::m_nickIndexMutex, and LIB_TABLE::m_rows.
Referenced by SYMBOL_LIB_TABLE::FindRow(), FP_LIB_TABLE::FindRow(), LIB_TABLE::GetDescription(), LIB_TABLE::GetFullURI(), and LIB_TABLE::HasLibrary().
|
inherited |
Definition at line 232 of file lib_table_base.cpp.
References LIB_TABLE::ensureIndex(), LIB_TABLE::m_fallBack, and LIB_TABLE::m_rows.
Referenced by PCB_EDIT_FRAME::ExportFootprintsToLibrary(), SYMBOL_EDIT_FRAME::KiwayMailIn(), and FOOTPRINT_EDIT_FRAME::KiwayMailIn().
|
inlineoverrideprivatevirtual |
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
aOutput | is the OUTPUTFORMATTER to format the table into. |
aIndentLevel | is the indentation level (2 spaces) to indent. |
IO_ERROR | if an I/O error occurs during output. |
boost::interprocess::lock_except | if separate process attempt to access the table. |
Implements LIB_TABLE.
Definition at line 99 of file test_lib_table.cpp.
|
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.
aProperties | is the PROPERTIES to format or NULL. If NULL the returned string will be empty. |
Definition at line 447 of file lib_table_base.cpp.
References UTF8::begin(), UTF8::end(), name, OPT_SEP, and UTF8::size().
Referenced by DIALOG_PLUGIN_OPTIONS::TransferDataFromWindow().
|
inlineinherited |
Get the number of rows contained in the table.
Definition at line 373 of file lib_table_base.h.
References LIB_TABLE::m_rows.
Referenced by BOOST_AUTO_TEST_CASE(), FP_TREE_SYNCHRONIZING_ADAPTER::GetLibrariesCount(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), and PCB::IFACE::SaveFileAs().
|
inherited |
Definition at line 139 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(), FOOTPRINT_EDIT_FRAME::buildSaveAsDialog(), SYMBOL_EDIT_FRAME::buildSaveAsDialog(), and PCB_BASE_FRAME::SelectLibrary().
|
inherited |
Return the full URI of the library mapped to aLibNickname.
Definition at line 174 of file lib_table_base.cpp.
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().
|
inherited |
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
Definition at line 268 of file lib_table_base.cpp.
References LIB_TABLE::m_fallBack, and LIB_TABLE::m_rows.
Referenced by FP_TREE_MODEL_ADAPTER::AddLibraries(), CVPCB_MAINFRAME::BuildLibrariesListBox(), FOOTPRINT_EDIT_FRAME::buildSaveAsDialog(), SYMBOL_EDIT_FRAME::buildSaveAsDialog(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FP_LIB_TABLE::FootprintLoadWithOptionalNickname(), FP_LIB_TABLE::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_LIST_IMPL::ReadFootprintFiles(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), PCB_BASE_FRAME::SelectLibrary(), and FP_TREE_SYNCHRONIZING_ADAPTER::Sync().
|
inlineinherited |
Returns the version number (0 if unset)
Definition at line 526 of file lib_table_base.h.
References LIB_TABLE::m_version.
|
inherited |
Test for the existence of aNickname in the library table.
aCheckEnabled | if true will only return true for enabled libraries |
Definition at line 151 of file lib_table_base.cpp.
References LIB_TABLE::findRow().
Referenced by SYMBOL_EDIT_FRAME::addLibTableEntry(), BOARD_INSPECTION_TOOL::DiffFootprint(), EE_INSPECTION_TOOL::DiffSymbol(), CVPCB_MAINFRAME::DisplayStatus(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), SYMBOL_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), SCH_ALTIUM_PLUGIN::Load(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), SCH_EDIT_FRAME::LoadSheetFromFile(), NETLIST_EXPORTER_XML::makeLibraries(), PCM_FP_LIB_TRAVERSER::OnDir(), PCM_SYM_LIB_TRAVERSER::OnFile(), SCH_BASE_FRAME::PickSymbolFromLibTree(), DRC_TEST_PROVIDER_LIBRARY_PARITY::Run(), FOOTPRINT_VIEWER_FRAME::ShowModal(), SYMBOL_VIEWER_FRAME::ShowModal(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), ERC_TESTER::TestLibSymbolIssues(), and SCH_SCREEN::UpdateSymbolLinks().
|
inherited |
Test for the existence of aPath in the library table.
aCheckEnabled | if true will only return true for enabled libraries |
Definition at line 162 of file lib_table_base.cpp.
References LIB_TABLE::m_rows.
Referenced by PCM_FP_LIB_TRAVERSER::OnDir(), and PCM_SYM_LIB_TRAVERSER::OnFile().
|
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.
aRow | is the new row to insert, or to forcibly add if doReplace is true. |
doReplace | if true, means insert regardless of whether aRow's key already exists. If false, then fail if the key already exists. |
Definition at line 304 of file lib_table_base.cpp.
References LIB_TABLE::ensureIndex(), LIB_TABLE_ROW::GetNickName(), LIB_TABLE::m_nickIndex, LIB_TABLE::m_nickIndexMutex, LIB_TABLE::m_rows, and LIB_TABLE_ROW::SetParent().
Referenced by SYMBOL_LIBRARY_MANAGER::addLibrary(), PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), LIB_TABLE_TEST_FIXTURE::LIB_TABLE_TEST_FIXTURE(), SCH_ALTIUM_PLUGIN::Load(), CADSTAR_SCH_ARCHIVE_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), PCM_FP_LIB_TRAVERSER::OnDir(), PCM_SYM_LIB_TRAVERSER::OnFile(), PCB_EDIT_FRAME::OpenProjectFiles(), SYMBOL_LIB_TABLE::Parse(), and FP_LIB_TABLE::Parse().
|
inherited |
Return true if the table is empty.
aIncludeFallback | is used to determine if the fallback table should be included in the test. |
Definition at line 130 of file lib_table_base.cpp.
References LIB_TABLE::IsEmpty(), LIB_TABLE::m_fallBack, and LIB_TABLE::m_rows.
Referenced by BOOST_AUTO_TEST_CASE(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), LIB_TABLE::IsEmpty(), and SCH_EDIT_FRAME::LoadSheetFromFile().
|
inherited |
Load the library table using the path defined by aFileName aFallBackTable.
aFileName | contains the full path to the s-expression file. |
IO_ERROR | if an error occurs attempting to load the footprint library table. |
Definition at line 356 of file lib_table_base.cpp.
References LIB_TABLE::m_version, LIB_TABLE::migrate(), LIB_TABLE::Parse(), and LIB_TABLE::Save().
Referenced by FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), SCH_EDIT_FRAME::LoadSheetFromFile(), PROJECT::PcbFootprintLibs(), PCB::IFACE::SaveFileAs(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow(), and WriteDRCReport().
|
protectedinherited |
Updates the env vars from older version of KiCad, provided they do not currently resolve to anything.
Definition at line 331 of file lib_table_base.cpp.
References LIB_TABLE::m_rows.
Referenced by LIB_TABLE::Load().
|
inlineinherited |
Definition at line 368 of file lib_table_base.h.
|
inlineinherited |
Compares this table against another.
This compares the row contents against each other. Any fallback tables are not checked.
Definition at line 352 of file lib_table_base.h.
References LIB_TABLE::m_rows.
|
inlineoverrideprivatevirtual |
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objects.
aLexer | is the lexer to parse. |
IO_ERROR | if an I/O error occurs during parsing. |
PARSER_ERROR | if the lexer format to parse is invalid. |
boost::bad_pointer | if an any attempt to add an invalid pointer to the boost::ptr_vector. |
boost::bad_index | if an index outside the row table bounds is accessed. |
Implements LIB_TABLE.
Definition at line 93 of file test_lib_table.cpp.
|
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 382 of file lib_table_base.cpp.
Referenced by LIB_TABLE_ROW::SetOptions(), and DIALOG_PLUGIN_OPTIONS::TransferDataToWindow().
|
inlineprotectedinherited |
Rebuilds the m_nickIndex.
aForce | is to avoid rebuilding the index multiple times because multiple threads hit ensureIndex at the same time |
Definition at line 556 of file lib_table_base.h.
References LIB_TABLE::m_nickIndex, LIB_TABLE::m_nickIndexMutex, and LIB_TABLE::m_rows.
Referenced by LIB_TABLE::ensureIndex(), LIB_TABLE::RemoveRow(), PANEL_SYM_LIB_TABLE::TransferDataFromWindow(), and PANEL_FP_LIB_TABLE::TransferDataFromWindow().
|
inlineinherited |
Removes a row from the table.
aRow | is the row to remove |
Definition at line 458 of file lib_table_base.h.
References LIB_TABLE::m_rows, and LIB_TABLE::reindex().
Referenced by SYMBOL_LIBRARY_MANAGER::addLibrary(), FP_LIB_TABLE::LoadGlobalTable(), and SYMBOL_LIB_TABLE::LoadGlobalTable().
|
inherited |
Write this library table to aFileName in s-expression form.
aFileName | is the name of the file to write to. |
Definition at line 372 of file lib_table_base.cpp.
References LIB_TABLE::Format(), and LIB_TABLE::m_version.
Referenced by PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), LIB_TABLE::Load(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), PCB_EDIT_FRAME::OpenProjectFiles(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), PCB::IFACE::SaveFileAs(), SCH_BASE_FRAME::saveSymbolLibTables(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), and DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow().
|
inlineoverridevirtual |
Implements PROJECT::_ELEM.
Definition at line 86 of file test_lib_table.cpp.
References FP_LIB_TABLE_T.
|
protectedinherited |
Definition at line 597 of file lib_table_base.h.
Referenced by LIB_TABLE::findRow(), LIB_TABLE::FindRowByURI(), LIB_TABLE::GetLogicalLibs(), and LIB_TABLE::IsEmpty().
|
protectedinherited |
this particular key is the nickName within each row.
Definition at line 595 of file lib_table_base.h.
Referenced by LIB_TABLE::Clear(), LIB_TABLE::ensureIndex(), LIB_TABLE::findRow(), LIB_TABLE::InsertRow(), and LIB_TABLE::reindex().
|
mutableprotectedinherited |
Mutex to protect access to the nickIndex variable.
Definition at line 603 of file lib_table_base.h.
Referenced by LIB_TABLE::Clear(), LIB_TABLE::findRow(), LIB_TABLE::InsertRow(), and LIB_TABLE::reindex().
|
protectedinherited |
Definition at line 586 of file lib_table_base.h.
Referenced by SYMBOL_LIB_TABLE_GRID::at(), FP_LIB_TABLE_GRID::at(), LIB_TABLE::At(), SYMBOL_LIB_TABLE_GRID::begin(), FP_LIB_TABLE_GRID::begin(), LIB_TABLE::Clear(), SYMBOL_LIB_TABLE_GRID::erase(), FP_LIB_TABLE_GRID::erase(), LIB_TABLE::findRow(), LIB_TABLE::FindRowByURI(), SYMBOL_LIB_TABLE::Format(), FP_LIB_TABLE::Format(), FP_LIB_TABLE_GRID::FP_LIB_TABLE_GRID(), LIB_TABLE::GetCount(), LIB_TABLE::GetLogicalLibs(), LIB_TABLE::HasLibraryWithPath(), SYMBOL_LIB_TABLE_GRID::insert(), FP_LIB_TABLE_GRID::insert(), LIB_TABLE::InsertRow(), LIB_TABLE::IsEmpty(), LIB_TABLE::migrate(), PANEL_SYM_LIB_TABLE::moveDownHandler(), PANEL_FP_LIB_TABLE::moveDownHandler(), PANEL_SYM_LIB_TABLE::moveUpHandler(), PANEL_FP_LIB_TABLE::moveUpHandler(), FP_LIB_TABLE::operator==(), LIB_TABLE::operator==(), SYMBOL_LIB_TABLE::operator==(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), SYMBOL_LIB_TABLE_GRID::push_back(), FP_LIB_TABLE_GRID::push_back(), LIB_TABLE::reindex(), LIB_TABLE::RemoveRow(), SYMBOL_LIB_TABLE_GRID::size(), FP_LIB_TABLE_GRID::size(), SYMBOL_LIB_TABLE_GRID::SYMBOL_LIB_TABLE_GRID(), PANEL_SYM_LIB_TABLE::TransferDataFromWindow(), and PANEL_FP_LIB_TABLE::TransferDataFromWindow().
|
mutableprotectedinherited |
Versioning to handle importing old tables.
Definition at line 600 of file lib_table_base.h.
Referenced by SYMBOL_LIB_TABLE::Format(), FP_LIB_TABLE::Format(), LIB_TABLE::GetVersion(), LIB_TABLE::Load(), SYMBOL_LIB_TABLE::Parse(), FP_LIB_TABLE::Parse(), and LIB_TABLE::Save().