KiCad PCB EDA Suite
|
#include <library_manager.h>
Public Member Functions | |
LIBRARY_MANAGER () | |
~LIBRARY_MANAGER () | |
LIBRARY_MANAGER (const LIBRARY_MANAGER &)=delete | |
LIBRARY_MANAGER & | operator= (const LIBRARY_MANAGER &)=delete |
void | LoadGlobalTables (std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={}) |
(Re)loads the global library tables in the given list, or all tables if no list is given | |
void | ProjectChanged () |
Notify all adapters that the project has changed. | |
void | RegisterAdapter (LIBRARY_TABLE_TYPE aType, std::unique_ptr< LIBRARY_MANAGER_ADAPTER > &&aAdapter) |
std::optional< LIBRARY_MANAGER_ADAPTER * > | Adapter (LIBRARY_TABLE_TYPE aType) const |
std::optional< LIBRARY_TABLE * > | Table (LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope) |
Retrieves a given table; creating a new empty project table if a valid project is loaded and the given table type doesn't exist in the project. | |
std::vector< LIBRARY_TABLE_ROW * > | Rows (LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH, bool aIncludeInvalid=false) const |
Returns a flattened list of libraries of the given type. | |
std::optional< LIBRARY_TABLE_ROW * > | GetRow (LIBRARY_TABLE_TYPE aType, const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const |
std::optional< LIBRARY_TABLE_ROW * > | FindRowByURI (LIBRARY_TABLE_TYPE aType, const wxString &aUri, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const |
void | LoadProjectTables (const wxString &aProjectPath) |
LIBRARY_RESULT< void > | Save (LIBRARY_TABLE *aTable) const |
std::optional< wxString > | GetFullURI (LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false) const |
Return the full location specifying URI for the LIB, either in original UI form or in environment variable expanded form. | |
Static Public Member Functions | |
static wxString | DefaultGlobalTablePath (LIBRARY_TABLE_TYPE aType) |
static bool | IsTableValid (const wxString &aPath) |
static bool | GlobalTablesValid () |
static std::vector< LIBRARY_TABLE_TYPE > | InvalidGlobalTables () |
static bool | CreateGlobalTable (LIBRARY_TABLE_TYPE aType, bool aPopulateDefaultLibraries) |
static wxString | GetFullURI (const LIBRARY_TABLE_ROW *aRow, bool aSubstituted=false) |
static wxString | ExpandURI (const wxString &aShortURI, const PROJECT &aProject) |
static bool | UrisAreEquivalent (const wxString &aURI1, const wxString &aURI2) |
Private Member Functions | |
void | loadTables (const wxString &aTablePath, LIBRARY_TABLE_SCOPE aScope, std::vector< LIBRARY_TABLE_TYPE > aTablesToLoad={}) |
void | loadNestedTables (LIBRARY_TABLE &aTable) |
void | createEmptyTable (LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope) |
Static Private Member Functions | |
static wxString | tableFileName (LIBRARY_TABLE_TYPE aType) |
Private Attributes | |
std::map< LIBRARY_TABLE_TYPE, std::unique_ptr< LIBRARY_TABLE > > | m_tables |
std::map< wxString, std::unique_ptr< LIBRARY_TABLE > > | m_childTables |
Map of full URI to table object for tables that are referenced by global or project tables. | |
std::map< LIBRARY_TABLE_TYPE, std::unique_ptr< LIBRARY_TABLE > > | m_projectTables |
std::map< LIBRARY_TABLE_TYPE, std::unique_ptr< LIBRARY_MANAGER_ADAPTER > > | m_adapters |
Definition at line 200 of file library_manager.h.
LIBRARY_MANAGER::LIBRARY_MANAGER | ( | ) |
Definition at line 45 of file library_manager.cpp.
Referenced by LIBRARY_MANAGER(), and operator=().
|
default |
|
delete |
References LIBRARY_MANAGER().
std::optional< LIBRARY_MANAGER_ADAPTER * > LIBRARY_MANAGER::Adapter | ( | LIBRARY_TABLE_TYPE | aType | ) | const |
Definition at line 499 of file library_manager.cpp.
References m_adapters.
Referenced by PROJECT::DesignBlockLibs(), and PROJECT_SCH::SymbolLibAdapter().
|
private |
Definition at line 163 of file library_manager.cpp.
References GetSettingsManager(), PATHS::GetUserSettingsPath(), GLOBAL, m_projectTables, m_tables, Pgm(), Prj(), PROJECT, and tableFileName().
Referenced by Table().
|
static |
Definition at line 365 of file library_manager.cpp.
References _, DefaultGlobalTablePath(), PATHS::GetStockTemplatesPath(), GLOBAL, LIBRARY_TABLE_ROW::SetDescription(), LIBRARY_TABLE_ROW::SetNickname(), LIBRARY_TABLE_ROW::SetType(), LIBRARY_TABLE_ROW::SetURI(), table, LIBRARY_TABLE_ROW::TABLE_TYPE_NAME, tableFileName(), traceLibraries, and IO_ERROR::What().
Referenced by STARTWIZARD_PROVIDER_LIBRARIES::ApplyDefaults(), STARTWIZARD_PROVIDER_LIBRARIES::Finish(), PANEL_FP_LIB_TABLE::onReset(), PANEL_SYM_LIB_TABLE::onReset(), and operator=().
|
static |
Definition at line 319 of file library_manager.cpp.
References FN_NORMALIZE_FLAGS, PATHS::GetUserSettingsPath(), and tableFileName().
Referenced by CreateGlobalTable(), operator=(), and PANEL_STARTWIZARD_LIBRARIES::TransferDataToWindow().
|
static |
Definition at line 723 of file library_manager.cpp.
References ExpandEnvVarSubstitutions(), and path.
Referenced by LIBRARY_MANAGER_ADAPTER::getUri(), LIBRARY_TABLE::HasRowWithURI(), DESIGN_BLOCK_LIB_TABLE_GRID::SetValue(), FP_LIB_TABLE_GRID::SetValue(), and SYMBOL_LIB_TABLE_GRID::SetValue().
std::optional< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER::FindRowByURI | ( | LIBRARY_TABLE_TYPE | aType, |
const wxString & | aUri, | ||
LIBRARY_TABLE_SCOPE | aScope = LIBRARY_TABLE_SCOPE::BOTH ) const |
Definition at line 637 of file library_manager.cpp.
References GetFullURI(), Rows(), and UrisAreEquivalent().
Referenced by DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable().
|
static |
Definition at line 713 of file library_manager.cpp.
References ExpandEnvVarSubstitutions(), and LIBRARY_TABLE_ROW::URI().
std::optional< wxString > LIBRARY_MANAGER::GetFullURI | ( | LIBRARY_TABLE_TYPE | aType, |
const wxString & | aNickname, | ||
bool | aSubstituted = false ) const |
Return the full location specifying URI for the LIB, either in original UI form or in environment variable expanded form.
aType | determines which tables will be searched for the library |
aNickname | is the library to look up |
aSubstituted | Tells if caller wanted the substituted form, else not. |
Definition at line 702 of file library_manager.cpp.
References GetFullURI(), GetRow(), and result.
Referenced by SYMBOL_VIEWER_FRAME::DisplayLibInfos(), SYMBOL_EDIT_FRAME::ExportSymbol(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), FindRowByURI(), GetFullURI(), SYMBOL_LIBRARY_MANAGER::GetLibraryHash(), SYMBOL_EDIT_FRAME::KiwayMailIn(), SYMBOL_VIEWER_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::LoadSheetFromFile(), NETLIST_EXPORTER_XML::makeLibraries(), SYMBOL_EDITOR_CONTROL::OpenDirectory(), SYMBOL_EDITOR_CONTROL::OpenWithTextEditor(), SYMBOL_LIBRARY_MANAGER::SaveLibrary(), SYMBOL_EDIT_FRAME::saveLibrary(), SCH_BASE_FRAME::setSymWatcher(), and ERC_TESTER::TestLibSymbolIssues().
std::optional< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER::GetRow | ( | LIBRARY_TABLE_TYPE | aType, |
const wxString & | aNickname, | ||
LIBRARY_TABLE_SCOPE | aScope = LIBRARY_TABLE_SCOPE::BOTH ) const |
aType | determines which type of libraries to return (symbol, footprint, ...) |
aScope | determines whether to search project, global, or both library tables |
aNickname | is the library nickname to retrieve |
Definition at line 623 of file library_manager.cpp.
References Rows().
Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_TREE_MODEL_ADAPTER::AddLibrary(), GetFullURI(), SYMBOL_EDIT_FRAME::LoadSymbol(), SYMBOL_LIB_TABLE_RESCUER::OpenRescueLibrary(), ERC_TESTER::TestLibSymbolIssues(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().
|
static |
Definition at line 342 of file library_manager.cpp.
References InvalidGlobalTables().
Referenced by STARTWIZARD_PROVIDER_LIBRARIES::NeedsUserInput(), and operator=().
|
static |
Definition at line 348 of file library_manager.cpp.
References DESIGN_BLOCK, FOOTPRINT, PATHS::GetUserSettingsPath(), IsTableValid(), SYMBOL, and tableFileName().
Referenced by STARTWIZARD_PROVIDER_LIBRARIES::ApplyDefaults(), STARTWIZARD_PROVIDER_LIBRARIES::Finish(), STARTWIZARD_PROVIDER_LIBRARIES::GetWizardPanel(), GlobalTablesValid(), and operator=().
|
static |
Definition at line 330 of file library_manager.cpp.
References GLOBAL, and LIBRARY_TABLE::IsOk().
Referenced by InvalidGlobalTables(), operator=(), and PANEL_STARTWIZARD_LIBRARIES::TransferDataToWindow().
void LIBRARY_MANAGER::LoadGlobalTables | ( | std::initializer_list< LIBRARY_TABLE_TYPE > | aTablesToLoad = {} | ) |
(Re)loads the global library tables in the given list, or all tables if no list is given
Definition at line 405 of file library_manager.cpp.
References DESIGN_BLOCK, FOOTPRINT, SETTINGS_MANAGER::GetAppSettings(), PGM_BASE::GetLibraryManager(), PGM_BASE::GetLocalEnvVariables(), PGM_BASE::GetSettingsManager(), PATHS::GetUserSettingsPath(), ENV_VAR::GetVersionedEnvVarValue(), GLOBAL, loadTables(), m_adapters, KICAD_SETTINGS::m_PcmLibAutoAdd, KICAD_SETTINGS::m_PcmLibAutoRemove, KICAD_SETTINGS::m_PcmLibPrefix, LIBRARY_ERROR::message, PCM_LIB_TRAVERSER::Modified(), Pgm(), Save(), SYMBOL, Table(), table, and traceLibraries.
Referenced by DESIGN_BLOCK_PANE::AddDesignBlockLibrary(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), InvokeEditDesignBlockLibTable(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), PGM_KICAD::OnPgmInit(), PANEL_FP_LIB_TABLE::onReset(), PANEL_SYM_LIB_TABLE::onReset(), and operator=().
|
private |
Definition at line 98 of file library_manager.cpp.
References _, m_childTables, WX_FILENAME::ResolvePossibleSymlinks(), LIBRARY_TABLE::Scope(), LIBRARY_TABLE_ROW::TABLE_TYPE_NAME, and traceLibraries.
Referenced by loadTables().
void LIBRARY_MANAGER::LoadProjectTables | ( | const wxString & | aProjectPath | ) |
Definition at line 651 of file library_manager.cpp.
References loadTables(), m_projectTables, PROJECT, and traceLibraries.
Referenced by BOOST_AUTO_TEST_CASE(), and ProjectChanged().
|
private |
Definition at line 53 of file library_manager.cpp.
References DESIGN_BLOCK, FOOTPRINT, GLOBAL, loadNestedTables(), m_projectTables, m_tables, PROJECT, SYMBOL, table, tableFileName(), and traceLibraries.
Referenced by LoadGlobalTables(), and LoadProjectTables().
|
delete |
void LIBRARY_MANAGER::ProjectChanged | ( | ) |
Notify all adapters that the project has changed.
Definition at line 481 of file library_manager.cpp.
References GetSettingsManager(), LoadProjectTables(), m_adapters, Pgm(), and Prj().
Referenced by DESIGN_BLOCK_PANE::AddDesignBlockLibrary(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), InvokeEditDesignBlockLibTable(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), and SETTINGS_MANAGER::LoadProject().
void LIBRARY_MANAGER::RegisterAdapter | ( | LIBRARY_TABLE_TYPE | aType, |
std::unique_ptr< LIBRARY_MANAGER_ADAPTER > && | aAdapter ) |
Definition at line 490 of file library_manager.cpp.
References m_adapters.
Referenced by PROJECT::DesignBlockLibs(), and PROJECT_SCH::SymbolLibAdapter().
std::vector< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER::Rows | ( | LIBRARY_TABLE_TYPE | aType, |
LIBRARY_TABLE_SCOPE | aScope = LIBRARY_TABLE_SCOPE::BOTH, | ||
bool | aIncludeInvalid = false ) const |
Returns a flattened list of libraries of the given type.
aType | determines which type of libraries to return (symbol, footprint, ...) |
aIncludeInvalid | will include the nicknames of libraries even if they could not be loaded for some reason (file not found, etc) |
Definition at line 548 of file library_manager.cpp.
References BOTH, GLOBAL, m_childTables, m_projectTables, m_tables, PROJECT, table, LIBRARY_TABLE_ROW::TABLE_TYPE_NAME, and UNINITIALIZED.
Referenced by DESIGN_BLOCK_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FindRowByURI(), SYMBOL_LIBRARY_MANAGER::GetLibraryNames(), and GetRow().
LIBRARY_RESULT< void > LIBRARY_MANAGER::Save | ( | LIBRARY_TABLE * | aTable | ) | const |
Definition at line 667 of file library_manager.cpp.
References FN_NORMALIZE_FLAGS, LIBRARY_TABLE::Format(), m_tables, LIBRARY_TABLE::Path(), traceLibraries, and IO_ERROR::What().
Referenced by DESIGN_BLOCK_PANE::AddDesignBlockLibrary(), SYMBOL_EDIT_FRAME::AddLibraryFile(), SYMBOL_EDIT_FRAME::addLibTableEntry(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), SYMBOL_EDIT_FRAME::DdAddLibrary(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), InvokeEditDesignBlockLibTable(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), SCH_EDIT_FRAME::KiwayMailIn(), LoadGlobalTables(), SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), SCH_IO_EAGLE::LoadSchematicFile(), SCH_IO_EASYEDAPRO::LoadSchematicFile(), SCH_EDIT_FRAME::LoadSheetFromFile(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().
std::optional< LIBRARY_TABLE * > LIBRARY_MANAGER::Table | ( | LIBRARY_TABLE_TYPE | aType, |
LIBRARY_TABLE_SCOPE | aScope ) |
Retrieves a given table; creating a new empty project table if a valid project is loaded and the given table type doesn't exist in the project.
aType | determines which type of table to return |
aScope | determines whether to return a global or project table |
Definition at line 508 of file library_manager.cpp.
References BOTH, createEmptyTable(), GetSettingsManager(), GLOBAL, m_projectTables, m_tables, Pgm(), Prj(), PROJECT, traceLibraries, and UNINITIALIZED.
Referenced by DESIGN_BLOCK_PANE::AddDesignBlockLibrary(), SYMBOL_LIBRARY_MANAGER::addLibrary(), SYMBOL_EDIT_FRAME::AddLibraryFile(), SYMBOL_EDIT_FRAME::addLibTableEntry(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), SYMBOL_EDIT_FRAME::DdAddLibrary(), InvokeEditDesignBlockLibTable(), InvokePcbLibTableEditor(), InvokeSchEditSymbolLibTable(), SCH_EDIT_FRAME::KiwayMailIn(), LoadGlobalTables(), PANEL_FP_LIB_TABLE::onReset(), PANEL_SYM_LIB_TABLE::onReset(), PANEL_DESIGN_BLOCK_LIB_TABLE::PANEL_DESIGN_BLOCK_LIB_TABLE(), PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE(), PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), PANEL_DESIGN_BLOCK_LIB_TABLE::TransferDataFromWindow(), PANEL_FP_LIB_TABLE::TransferDataFromWindow(), PANEL_SYM_LIB_TABLE::TransferDataFromWindow(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().
|
staticprivate |
Definition at line 151 of file library_manager.cpp.
References DESIGN_BLOCK, FILEEXT::DesignBlockLibraryTableFileName, FOOTPRINT, FILEEXT::FootprintLibraryTableFileName, SYMBOL, and FILEEXT::SymbolLibraryTableFileName.
Referenced by createEmptyTable(), CreateGlobalTable(), DefaultGlobalTablePath(), InvalidGlobalTables(), and loadTables().
|
static |
Definition at line 731 of file library_manager.cpp.
Referenced by LIBRARY_MANAGER_ADAPTER::FindLibraryByURI(), and FindRowByURI().
|
private |
Definition at line 312 of file library_manager.h.
Referenced by Adapter(), LoadGlobalTables(), ProjectChanged(), and RegisterAdapter().
|
private |
Map of full URI to table object for tables that are referenced by global or project tables.
Definition at line 307 of file library_manager.h.
Referenced by loadNestedTables(), and Rows().
|
private |
Definition at line 310 of file library_manager.h.
Referenced by createEmptyTable(), LoadProjectTables(), loadTables(), Rows(), and Table().
|
private |
Definition at line 304 of file library_manager.h.
Referenced by createEmptyTable(), loadTables(), Rows(), Save(), and Table().