KiCad PCB EDA Suite
|
The interface used by the classes that actually can load IO plugins for the different parts of KiCad and return concrete types (symbols, footprints, etc) More...
#include <library_manager.h>
Public Member Functions | |
LIBRARY_MANAGER_ADAPTER (LIBRARY_MANAGER &aManager) | |
Constructs a type-specific adapter into the library manager. | |
virtual | ~LIBRARY_MANAGER_ADAPTER () |
LIBRARY_MANAGER & | Manager () const |
virtual LIBRARY_TABLE_TYPE | Type () const =0 |
The type of library table this adapter works with. | |
LIBRARY_TABLE * | GlobalTable () const |
Retrieves the global library table for this adapter type. | |
std::optional< LIBRARY_TABLE * > | ProjectTable () const |
Retrieves the project library table for this adapter type, or nullopt if one doesn't exist. | |
std::optional< wxString > | FindLibraryByURI (const wxString &aURI) const |
std::vector< wxString > | GetLibraryNames () const |
Returns a list of library nicknames that are available (skips any that failed to load) | |
bool | HasLibrary (const wxString &aNickname, bool aCheckEnabled=false) const |
Test for the existence of aNickname in the library tables. | |
bool | DeleteLibrary (const wxString &aNickname) |
Deletes the given library from disk if it exists; returns true if deleted. | |
std::optional< wxString > | GetLibraryDescription (const wxString &aNickname) const |
std::vector< LIBRARY_TABLE_ROW * > | Rows (LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH, bool aIncludeInvalid=false) const |
Like LIBRARY_MANAGER::Rows but filtered to the LIBRARY_TABLE_TYPE of this adapter. | |
std::optional< LIBRARY_TABLE_ROW * > | GetRow (const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const |
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter. | |
std::optional< LIBRARY_TABLE_ROW * > | FindRowByURI (const wxString &aUri, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const |
Like LIBRARY_MANAGER::FindRowByURI but filtered to the LIBRARY_TABLE_TYPE of this adapter. | |
virtual void | ProjectChanged () |
Notify the adapter that the active project has changed. | |
void | GlobalTablesChanged (std::initializer_list< LIBRARY_TABLE_TYPE > aChangedTables={}) |
Notify the adapter that the global library tables have changed. | |
virtual void | AsyncLoad ()=0 |
Loads all available libraries for this adapter type in the background. | |
std::optional< float > | AsyncLoadProgress () const |
Returns async load progress between 0.0 and 1.0, or nullopt if load is not in progress. | |
void | BlockUntilLoaded () |
bool | IsLibraryLoaded (const wxString &aNickname) |
virtual bool | IsWritable (const wxString &aNickname) const |
Return true if the given nickname exists and is not a read-only library. | |
virtual bool | SupportsConfigurationDialog (const wxString &aNickname) const |
virtual void | ShowConfigurationDialog (const wxString &aNickname, wxWindow *aParent) const |
Protected Member Functions | |
virtual std::map< wxString, LIB_DATA > & | globalLibs ()=0 |
virtual std::map< wxString, LIB_DATA > & | globalLibs () const =0 |
virtual std::mutex & | globalLibsMutex ()=0 |
std::optional< const LIB_DATA * > | fetchIfLoaded (const wxString &aNickname) const |
std::optional< LIB_DATA * > | fetchIfLoaded (const wxString &aNickname) |
LIBRARY_RESULT< LIB_DATA * > | loadIfNeeded (const wxString &aNickname) |
Fetches a loaded library, triggering a load of that library if it isn't loaded yet. | |
void | abortLoad () |
Aborts any async load in progress; blocks until fully done aborting. | |
virtual LIBRARY_RESULT< IO_BASE * > | createPlugin (const LIBRARY_TABLE_ROW *row)=0 |
Creates a concrete plugin for the given row. | |
Static Protected Member Functions | |
static wxString | getUri (const LIBRARY_TABLE_ROW *aRow) |
Protected Attributes | |
LIBRARY_MANAGER & | m_manager |
std::map< wxString, LIB_DATA > | m_libraries |
std::mutex | m_libraries_mutex |
std::atomic_bool | m_abort |
std::vector< std::future< void > > | m_futures |
std::atomic< size_t > | m_loadCount |
size_t | m_loadTotal |
The interface used by the classes that actually can load IO plugins for the different parts of KiCad and return concrete types (symbols, footprints, etc)
Definition at line 84 of file library_manager.h.
LIBRARY_MANAGER_ADAPTER::LIBRARY_MANAGER_ADAPTER | ( | LIBRARY_MANAGER & | aManager | ) |
Constructs a type-specific adapter into the library manager.
The code for these generally resides in app-specific libraries (eeschema/pcbnew for example) rather than being in kicommon.
aManager | should usually be Pgm().GetLibraryManager() except in QA tests |
Definition at line 759 of file library_manager.cpp.
References m_loadTotal, and m_manager.
Referenced by DESIGN_BLOCK_LIBRARY_ADAPTER::DESIGN_BLOCK_LIBRARY_ADAPTER(), and SYMBOL_LIBRARY_ADAPTER::SYMBOL_LIBRARY_ADAPTER().
|
virtual |
Definition at line 765 of file library_manager.cpp.
|
protected |
Aborts any async load in progress; blocks until fully done aborting.
Definition at line 914 of file library_manager.cpp.
References BlockUntilLoaded(), m_abort, m_futures, m_loadTotal, and traceLibraries.
Referenced by globalLibsMutex(), GlobalTablesChanged(), and ProjectChanged().
|
pure virtual |
Loads all available libraries for this adapter type in the background.
Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.
References AsyncLoadProgress(), BlockUntilLoaded(), and IsLibraryLoaded().
std::optional< float > LIBRARY_MANAGER_ADAPTER::AsyncLoadProgress | ( | ) | const |
Returns async load progress between 0.0 and 1.0, or nullopt if load is not in progress.
Definition at line 931 of file library_manager.cpp.
References m_loadCount, and m_loadTotal.
Referenced by AsyncLoad(), BOOST_AUTO_TEST_CASE(), PGM_BASE::PreloadDesignBlockLibraries(), and SCH::IFACE::PreloadLibraries().
void LIBRARY_MANAGER_ADAPTER::BlockUntilLoaded | ( | ) |
Definition at line 941 of file library_manager.cpp.
References m_futures.
Referenced by abortLoad(), AsyncLoad(), BOOST_AUTO_TEST_CASE(), EESCHEMA_JOBS_HANDLER::JobSchErc(), PGM_BASE::PreloadDesignBlockLibraries(), and SCH::IFACE::PreloadLibraries().
|
protectedpure virtual |
Creates a concrete plugin for the given row.
Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.
Referenced by loadIfNeeded().
bool LIBRARY_MANAGER_ADAPTER::DeleteLibrary | ( | const wxString & | aNickname | ) |
Deletes the given library from disk if it exists; returns true if deleted.
Definition at line 862 of file library_manager.cpp.
References IO_BASE::DeleteLibrary(), LIBRARY_TABLE_ROW::GetOptionsMap(), getUri(), loadIfNeeded(), LIB_DATA::plugin, result, and LIB_DATA::row.
Referenced by Type().
|
protected |
Definition at line 988 of file library_manager.cpp.
References globalLibs(), LOADED, and m_libraries.
|
protected |
Definition at line 969 of file library_manager.cpp.
References globalLibs(), LOADED, and m_libraries.
Referenced by DESIGN_BLOCK_LIBRARY_ADAPTER::DeleteDesignBlock(), DESIGN_BLOCK_LIBRARY_ADAPTER::DesignBlockExists(), SYMBOL_LIBRARY_ADAPTER::GetAvailableExtraFields(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetDesignBlockNames(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetDesignBlocks(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetEnumeratedDesignBlock(), GetLibraryDescription(), GetLibraryNames(), SYMBOL_LIBRARY_ADAPTER::GetModifyHash(), SYMBOL_LIBRARY_ADAPTER::GetSubLibraries(), SYMBOL_LIBRARY_ADAPTER::GetSymbolNames(), SYMBOL_LIBRARY_ADAPTER::GetSymbols(), globalLibsMutex(), HasLibrary(), DESIGN_BLOCK_LIBRARY_ADAPTER::IsDesignBlockLibWritable(), SYMBOL_LIBRARY_ADAPTER::IsWritable(), DESIGN_BLOCK_LIBRARY_ADAPTER::LoadDesignBlock(), SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), DESIGN_BLOCK_LIBRARY_ADAPTER::SaveDesignBlock(), SYMBOL_LIBRARY_ADAPTER::ShowConfigurationDialog(), SYMBOL_LIBRARY_ADAPTER::SupportsConfigurationDialog(), and SYMBOL_LIBRARY_ADAPTER::SupportsSubLibraries().
std::optional< wxString > LIBRARY_MANAGER_ADAPTER::FindLibraryByURI | ( | const wxString & | aURI | ) | const |
Definition at line 826 of file library_manager.cpp.
References m_manager, Type(), and LIBRARY_MANAGER::UrisAreEquivalent().
Referenced by Type().
std::optional< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER_ADAPTER::FindRowByURI | ( | const wxString & | aUri, |
LIBRARY_TABLE_SCOPE | aScope = LIBRARY_TABLE_SCOPE::BOTH ) const |
Like LIBRARY_MANAGER::FindRowByURI but filtered to the LIBRARY_TABLE_TYPE of this adapter.
Definition at line 906 of file library_manager.cpp.
References m_manager, and Type().
Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn(), and Type().
std::optional< wxString > LIBRARY_MANAGER_ADAPTER::GetLibraryDescription | ( | const wxString & | aNickname | ) | const |
Definition at line 883 of file library_manager.cpp.
References fetchIfLoaded().
Referenced by SCH_BASE_FRAME::GetLibraryItemsForListDialog(), and Type().
std::vector< wxString > LIBRARY_MANAGER_ADAPTER::GetLibraryNames | ( | ) | const |
Returns a list of library nicknames that are available (skips any that failed to load)
Definition at line 838 of file library_manager.cpp.
References fetchIfLoaded(), m_manager, and Type().
Referenced by DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), DESIGN_BLOCK_LIBRARY_ADAPTER::DesignBlockLoadWithOptionalNickname(), SYMBOL_LIBRARY_MANAGER::GetLibraryCount(), SCH_BASE_FRAME::GetLibraryItemsForListDialog(), DIALOG_EDIT_SYMBOLS_LIBID::onClickOrphansButton(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), and Type().
std::optional< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER_ADAPTER::GetRow | ( | const wxString & | aNickname, |
LIBRARY_TABLE_SCOPE | aScope = LIBRARY_TABLE_SCOPE::BOTH ) const |
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
Definition at line 899 of file library_manager.cpp.
References m_manager, and Type().
Referenced by SYMBOL_VIEWER_FRAME::DisplayLibInfos(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), SYMBOL_EDIT_FRAME::IsSymbolFromLegacyLibrary(), SYMBOL_EDIT_FRAME::KiwayMailIn(), SYMBOL_VIEWER_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::LoadSheetFromFile(), PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), SYMBOL_EDIT_FRAME::replaceLibTableEntry(), SYMBOL_EDIT_FRAME::saveLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), and Type().
|
staticprotected |
Definition at line 963 of file library_manager.cpp.
References LIBRARY_MANAGER::ExpandURI(), GetSettingsManager(), Pgm(), Prj(), and LIBRARY_TABLE_ROW::URI().
Referenced by SYMBOL_LIBRARY_ADAPTER::CreateLibrary(), DESIGN_BLOCK_LIBRARY_ADAPTER::DeleteDesignBlock(), DeleteLibrary(), DESIGN_BLOCK_LIBRARY_ADAPTER::DesignBlockExists(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetDesignBlockNames(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetDesignBlocks(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetEnumeratedDesignBlock(), SYMBOL_LIBRARY_ADAPTER::GetSymbolNames(), SYMBOL_LIBRARY_ADAPTER::GetSymbols(), globalLibsMutex(), DESIGN_BLOCK_LIBRARY_ADAPTER::IsDesignBlockLibWritable(), SYMBOL_LIBRARY_ADAPTER::IsSymbolLibWritable(), SYMBOL_LIBRARY_ADAPTER::IsWritable(), DESIGN_BLOCK_LIBRARY_ADAPTER::LoadDesignBlock(), SYMBOL_LIBRARY_ADAPTER::LoadOne(), SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), and DESIGN_BLOCK_LIBRARY_ADAPTER::SaveDesignBlock().
|
protectedpure virtual |
Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.
|
protectedpure virtual |
Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.
Referenced by fetchIfLoaded(), fetchIfLoaded(), GlobalTablesChanged(), IsLibraryLoaded(), and loadIfNeeded().
|
protectedpure virtual |
Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.
References abortLoad(), fetchIfLoaded(), getUri(), and loadIfNeeded().
Referenced by GlobalTablesChanged(), and loadIfNeeded().
LIBRARY_TABLE * LIBRARY_MANAGER_ADAPTER::GlobalTable | ( | ) | const |
Retrieves the global library table for this adapter type.
Definition at line 813 of file library_manager.cpp.
References GLOBAL, m_manager, and Type().
Referenced by SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), and Type().
void LIBRARY_MANAGER_ADAPTER::GlobalTablesChanged | ( | std::initializer_list< LIBRARY_TABLE_TYPE > | aChangedTables = {} | ) |
Notify the adapter that the global library tables have changed.
Definition at line 787 of file library_manager.cpp.
References abortLoad(), globalLibs(), globalLibsMutex(), and Type().
Referenced by Type().
bool LIBRARY_MANAGER_ADAPTER::HasLibrary | ( | const wxString & | aNickname, |
bool | aCheckEnabled = false ) const |
Test for the existence of aNickname in the library tables.
aCheckEnabled | if true will only return true for enabled libraries |
Definition at line 852 of file library_manager.cpp.
References fetchIfLoaded().
Referenced by SYMBOL_EDIT_FRAME::AddLibraryFile(), SYMBOL_EDIT_FRAME::addLibTableEntry(), SYMBOL_VIEWER_FRAME::ClickOnLibList(), SYMBOL_EDIT_FRAME::DdAddLibrary(), SCH_INSPECTION_TOOL::DiffSymbol(), SYMBOL_EDIT_FRAME::KiwayMailIn(), SYMBOL_LIBRARY_MANAGER::LibraryExists(), SCH_EDIT_FRAME::LoadSheetFromFile(), PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER(), SYMBOL_EDIT_FRAME::saveLibrary(), SCH_BASE_FRAME::SelectLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), Type(), and SCH_SCREEN::UpdateSymbolLinks().
bool LIBRARY_MANAGER_ADAPTER::IsLibraryLoaded | ( | const wxString & | aNickname | ) |
Definition at line 948 of file library_manager.cpp.
References globalLibs(), and m_libraries.
Referenced by AsyncLoad(), SYMBOL_LIBRARY_MANAGER::IsLibraryLoaded(), and ERC_TESTER::TestLibSymbolIssues().
|
inlinevirtual |
Return true if the given nickname exists and is not a read-only library.
Reimplemented in SYMBOL_LIBRARY_ADAPTER.
Definition at line 156 of file library_manager.h.
|
protected |
Fetches a loaded library, triggering a load of that library if it isn't loaded yet.
Definition at line 1004 of file library_manager.cpp.
References _, createPlugin(), GLOBAL, globalLibs(), globalLibsMutex(), LOADING, m_libraries, m_libraries_mutex, m_manager, LIBRARY_TABLE_ROW::Nickname(), PROJECT, result, traceLibraries, and Type().
Referenced by SYMBOL_LIBRARY_ADAPTER::CreateLibrary(), DeleteLibrary(), globalLibsMutex(), and SYMBOL_LIBRARY_ADAPTER::LoadOne().
LIBRARY_MANAGER & LIBRARY_MANAGER_ADAPTER::Manager | ( | ) | const |
Definition at line 770 of file library_manager.cpp.
References m_manager.
Referenced by SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), SCH_IO_EAGLE::LoadSchematicFile(), and SCH_IO_EASYEDAPRO::LoadSchematicFile().
|
virtual |
Notify the adapter that the active project has changed.
Definition at line 776 of file library_manager.cpp.
References abortLoad(), m_libraries, and m_libraries_mutex.
std::optional< LIBRARY_TABLE * > LIBRARY_MANAGER_ADAPTER::ProjectTable | ( | ) | const |
Retrieves the project library table for this adapter type, or nullopt if one doesn't exist.
Definition at line 820 of file library_manager.cpp.
References m_manager, PROJECT, and Type().
Referenced by SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), SCH_IO_EAGLE::LoadSchematicFile(), SCH_IO_EASYEDAPRO::LoadSchematicFile(), SCH_EDIT_FRAME::LoadSheetFromFile(), and Type().
std::vector< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER_ADAPTER::Rows | ( | LIBRARY_TABLE_SCOPE | aScope = LIBRARY_TABLE_SCOPE::BOTH, |
bool | aIncludeInvalid = false ) const |
Like LIBRARY_MANAGER::Rows but filtered to the LIBRARY_TABLE_TYPE of this adapter.
Definition at line 892 of file library_manager.cpp.
References m_manager, and Type().
Referenced by Type().
|
inlinevirtual |
Reimplemented in SYMBOL_LIBRARY_ADAPTER.
Definition at line 160 of file library_manager.h.
|
inlinevirtual |
Reimplemented in SYMBOL_LIBRARY_ADAPTER.
Definition at line 158 of file library_manager.h.
|
pure virtual |
The type of library table this adapter works with.
Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.
References BOTH, DeleteLibrary(), FindLibraryByURI(), FindRowByURI(), GetLibraryDescription(), GetLibraryNames(), GetRow(), GlobalTable(), GlobalTablesChanged(), HasLibrary(), ProjectTable(), and Rows().
Referenced by FindLibraryByURI(), FindRowByURI(), GetLibraryNames(), GetRow(), GlobalTable(), GlobalTablesChanged(), loadIfNeeded(), ProjectTable(), and Rows().
|
protected |
Definition at line 192 of file library_manager.h.
Referenced by abortLoad().
|
protected |
Definition at line 193 of file library_manager.h.
Referenced by abortLoad(), DESIGN_BLOCK_LIBRARY_ADAPTER::AsyncLoad(), SYMBOL_LIBRARY_ADAPTER::AsyncLoad(), and BlockUntilLoaded().
|
protected |
Definition at line 188 of file library_manager.h.
Referenced by DESIGN_BLOCK_LIBRARY_ADAPTER::AsyncLoad(), SYMBOL_LIBRARY_ADAPTER::AsyncLoad(), fetchIfLoaded(), fetchIfLoaded(), SYMBOL_LIBRARY_ADAPTER::GetLibraryStatus(), IsLibraryLoaded(), SYMBOL_LIBRARY_ADAPTER::IsSymbolLibWritable(), SYMBOL_LIBRARY_ADAPTER::LibraryError(), loadIfNeeded(), and ProjectChanged().
|
protected |
Definition at line 190 of file library_manager.h.
Referenced by DESIGN_BLOCK_LIBRARY_ADAPTER::AsyncLoad(), SYMBOL_LIBRARY_ADAPTER::AsyncLoad(), loadIfNeeded(), and ProjectChanged().
|
protected |
Definition at line 195 of file library_manager.h.
Referenced by DESIGN_BLOCK_LIBRARY_ADAPTER::AsyncLoad(), SYMBOL_LIBRARY_ADAPTER::AsyncLoad(), and AsyncLoadProgress().
|
protected |
Definition at line 196 of file library_manager.h.
Referenced by abortLoad(), DESIGN_BLOCK_LIBRARY_ADAPTER::AsyncLoad(), SYMBOL_LIBRARY_ADAPTER::AsyncLoad(), AsyncLoadProgress(), and LIBRARY_MANAGER_ADAPTER().
|
protected |
Definition at line 182 of file library_manager.h.
Referenced by DESIGN_BLOCK_LIBRARY_ADAPTER::AsyncLoad(), SYMBOL_LIBRARY_ADAPTER::AsyncLoad(), FindLibraryByURI(), FindRowByURI(), GetLibraryNames(), SYMBOL_LIBRARY_ADAPTER::GetLibraryStatuses(), SYMBOL_LIBRARY_ADAPTER::GetModifyHash(), GetRow(), GlobalTable(), LIBRARY_MANAGER_ADAPTER(), loadIfNeeded(), Manager(), ProjectTable(), and Rows().