KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LIBRARY_MANAGER_ADAPTER Class Referenceabstract

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>

Inheritance diagram for LIBRARY_MANAGER_ADAPTER:
DESIGN_BLOCK_LIBRARY_ADAPTER FOOTPRINT_LIBRARY_ADAPTER SYMBOL_LIBRARY_ADAPTER

Public Member Functions

 LIBRARY_MANAGER_ADAPTER (LIBRARY_MANAGER &aManager)
 Constructs a type-specific adapter into the library manager.
 
virtual ~LIBRARY_MANAGER_ADAPTER ()
 
LIBRARY_MANAGERManager () const
 
virtual LIBRARY_TABLE_TYPE Type () const =0
 The type of library table this adapter works with.
 
LIBRARY_TABLEGlobalTable () 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.
 
void CheckTableRow (LIBRARY_TABLE_ROW &aRow)
 
virtual void AsyncLoad ()=0
 Loads all available libraries for this adapter type in the background.
 
virtual std::optional< LIB_STATUSLoadOne (LIB_DATA *aLib)=0
 
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 std::optional< LIB_STATUSGetLibraryStatus (const wxString &aNickname) const =0
 Returns the status of a loaded library, or nullopt if the library hasn't been loaded (yet)
 
std::vector< std::pair< wxString, LIB_STATUS > > GetLibraryStatuses () const
 Returns a list of all library nicknames and their status (even if they failed to load)
 
void ReloadLibraryEntry (const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH)
 
virtual bool IsWritable (const wxString &aNickname) const
 Return true if the given nickname exists and is not a read-only library.
 
bool CreateLibrary (const wxString &aNickname)
 Creates the library (i.e. saves to disk) for the given row if it exists.
 
virtual bool SupportsConfigurationDialog (const wxString &aNickname) const
 
virtual void ShowConfigurationDialog (const wxString &aNickname, wxWindow *aParent) const
 
virtual std::optional< LIBRARY_ERRORLibraryError (const wxString &aNickname) 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.
 
LIBRARY_RESULT< LIB_DATA * > loadFromScope (const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope, std::map< wxString, LIB_DATA > &aTarget, std::mutex &aMutex)
 
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.
 
virtual IO_BASEplugin (const LIB_DATA *aRow)=0
 

Static Protected Member Functions

static wxString getUri (const LIBRARY_TABLE_ROW *aRow)
 

Protected Attributes

LIBRARY_MANAGERm_manager
 
std::map< wxString, LIB_DATAm_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
 

Detailed Description

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 70 of file library_manager.h.

Constructor & Destructor Documentation

◆ LIBRARY_MANAGER_ADAPTER()

LIBRARY_MANAGER_ADAPTER::LIBRARY_MANAGER_ADAPTER ( LIBRARY_MANAGER & aManager)

Constructs a type-specific adapter into the library manager.

LIBRARY_MANAGER_ADAPTER.

The code for these generally resides in app-specific libraries (eeschema/pcbnew for example) rather than being in kicommon.

Parameters
aManagershould usually be Pgm().GetLibraryManager() except in QA tests

Definition at line 740 of file library_manager.cpp.

References m_loadTotal, and m_manager.

Referenced by DESIGN_BLOCK_LIBRARY_ADAPTER::DESIGN_BLOCK_LIBRARY_ADAPTER(), FOOTPRINT_LIBRARY_ADAPTER::FOOTPRINT_LIBRARY_ADAPTER(), and SYMBOL_LIBRARY_ADAPTER::SYMBOL_LIBRARY_ADAPTER().

◆ ~LIBRARY_MANAGER_ADAPTER()

LIBRARY_MANAGER_ADAPTER::~LIBRARY_MANAGER_ADAPTER ( )
virtual

Definition at line 746 of file library_manager.cpp.

Member Function Documentation

◆ abortLoad()

void LIBRARY_MANAGER_ADAPTER::abortLoad ( )
protected

Aborts any async load in progress; blocks until fully done aborting.

Definition at line 925 of file library_manager.cpp.

References BlockUntilLoaded(), m_abort, m_futures, m_loadTotal, and traceLibraries.

Referenced by CheckTableRow(), globalLibsMutex(), GlobalTablesChanged(), and ProjectChanged().

◆ AsyncLoad()

virtual void LIBRARY_MANAGER_ADAPTER::AsyncLoad ( )
pure virtual

Loads all available libraries for this adapter type in the background.

Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, FOOTPRINT_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.

◆ AsyncLoadProgress()

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 942 of file library_manager.cpp.

References m_loadCount, and m_loadTotal.

Referenced by BOOST_AUTO_TEST_CASE(), LoadOne(), PGM_BASE::PreloadDesignBlockLibraries(), PCB::IFACE::PreloadLibraries(), and SCH::IFACE::PreloadLibraries().

◆ BlockUntilLoaded()

◆ CheckTableRow()

◆ CreateLibrary()

bool LIBRARY_MANAGER_ADAPTER::CreateLibrary ( const wxString & aNickname)

Creates the library (i.e. saves to disk) for the given row if it exists.

Definition at line 1079 of file library_manager.cpp.

References IO_BASE::CreateLibrary(), LIBRARY_TABLE_ROW::GetOptionsMap(), getUri(), loadIfNeeded(), LIB_DATA::plugin, result, and LIB_DATA::row.

Referenced by SYMBOL_LIBRARY_MANAGER::addLibrary(), and GetLibraryStatus().

◆ createPlugin()

virtual LIBRARY_RESULT< IO_BASE * > LIBRARY_MANAGER_ADAPTER::createPlugin ( const LIBRARY_TABLE_ROW * row)
protectedpure virtual

Creates a concrete plugin for the given row.

Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, FOOTPRINT_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.

Referenced by CheckTableRow(), and loadFromScope().

◆ DeleteLibrary()

bool LIBRARY_MANAGER_ADAPTER::DeleteLibrary ( const wxString & aNickname)

Deletes the given library from disk if it exists; returns true if deleted.

Definition at line 873 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().

◆ fetchIfLoaded() [1/2]

std::optional< LIB_DATA * > LIBRARY_MANAGER_ADAPTER::fetchIfLoaded ( const wxString & aNickname)
protected

Definition at line 1126 of file library_manager.cpp.

References globalLibs(), LOADED, and m_libraries.

◆ fetchIfLoaded() [2/2]

◆ FindLibraryByURI()

std::optional< wxString > LIBRARY_MANAGER_ADAPTER::FindLibraryByURI ( const wxString & aURI) const

Definition at line 837 of file library_manager.cpp.

References m_manager, Type(), and LIBRARY_MANAGER::UrisAreEquivalent().

Referenced by Type().

◆ FindRowByURI()

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 917 of file library_manager.cpp.

References m_manager, and Type().

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

◆ GetLibraryDescription()

std::optional< wxString > LIBRARY_MANAGER_ADAPTER::GetLibraryDescription ( const wxString & aNickname) const

◆ GetLibraryNames()

◆ GetLibraryStatus()

virtual std::optional< LIB_STATUS > LIBRARY_MANAGER_ADAPTER::GetLibraryStatus ( const wxString & aNickname) const
pure virtual

Returns the status of a loaded library, or nullopt if the library hasn't been loaded (yet)

Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, FOOTPRINT_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.

References BOTH, CreateLibrary(), GetLibraryStatuses(), IsWritable(), and ReloadLibraryEntry().

Referenced by GetLibraryStatuses().

◆ GetLibraryStatuses()

std::vector< std::pair< wxString, LIB_STATUS > > LIBRARY_MANAGER_ADAPTER::GetLibraryStatuses ( ) const

Returns a list of all library nicknames and their status (even if they failed to load)

Definition at line 990 of file library_manager.cpp.

References _, GetLibraryStatus(), LOAD_ERROR, m_manager, result, and Type().

Referenced by BOOST_AUTO_TEST_CASE(), GetLibraryStatus(), and SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync().

◆ GetRow()

◆ getUri()

◆ globalLibs() [1/2]

virtual std::map< wxString, LIB_DATA > & LIBRARY_MANAGER_ADAPTER::globalLibs ( ) const
protectedpure virtual

◆ globalLibs() [2/2]

virtual std::map< wxString, LIB_DATA > & LIBRARY_MANAGER_ADAPTER::globalLibs ( )
protectedpure virtual

◆ globalLibsMutex()

virtual std::mutex & LIBRARY_MANAGER_ADAPTER::globalLibsMutex ( )
protectedpure virtual

◆ GlobalTable()

LIBRARY_TABLE * LIBRARY_MANAGER_ADAPTER::GlobalTable ( ) const

Retrieves the global library table for this adapter type.

Definition at line 824 of file library_manager.cpp.

References GLOBAL, m_manager, and Type().

Referenced by SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), and Type().

◆ GlobalTablesChanged()

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 768 of file library_manager.cpp.

References abortLoad(), globalLibs(), globalLibsMutex(), and Type().

Referenced by Type().

◆ HasLibrary()

◆ IsLibraryLoaded()

bool LIBRARY_MANAGER_ADAPTER::IsLibraryLoaded ( const wxString & aNickname)

◆ IsWritable()

bool LIBRARY_MANAGER_ADAPTER::IsWritable ( const wxString & aNickname) const
virtual

Return true if the given nickname exists and is not a read-only library.

Definition at line 1067 of file library_manager.cpp.

References fetchIfLoaded(), getUri(), IO_BASE::IsLibraryWritable(), LIB_DATA::plugin, result, and LIB_DATA::row.

Referenced by GetLibraryStatus().

◆ LibraryError()

std::optional< LIBRARY_ERROR > LIBRARY_MANAGER_ADAPTER::LibraryError ( const wxString & aNickname) const
virtual

Definition at line 974 of file library_manager.cpp.

References globalLibs(), and m_libraries.

Referenced by LIB_TABLE_GRID_TRICKS::onGridCellLeftClick().

◆ loadFromScope()

LIBRARY_RESULT< LIB_DATA * > LIBRARY_MANAGER_ADAPTER::loadFromScope ( const wxString & aNickname,
LIBRARY_TABLE_SCOPE aScope,
std::map< wxString, LIB_DATA > & aTarget,
std::mutex & aMutex )
protected

◆ loadIfNeeded()

LIBRARY_RESULT< LIB_DATA * > LIBRARY_MANAGER_ADAPTER::loadIfNeeded ( const wxString & aNickname)
protected

Fetches a loaded library, triggering a load of that library if it isn't loaded yet.

Definition at line 1183 of file library_manager.cpp.

References _, GLOBAL, globalLibs(), globalLibsMutex(), loadFromScope(), m_libraries, m_libraries_mutex, PROJECT, and result.

Referenced by CreateLibrary(), DeleteLibrary(), globalLibsMutex(), FOOTPRINT_LIBRARY_ADAPTER::LoadOne(), SYMBOL_LIBRARY_ADAPTER::LoadOne(), and SYMBOL_LIBRARY_ADAPTER::SaveSymbol().

◆ LoadOne()

virtual std::optional< LIB_STATUS > LIBRARY_MANAGER_ADAPTER::LoadOne ( LIB_DATA * aLib)
pure virtual

◆ Manager()

LIBRARY_MANAGER & LIBRARY_MANAGER_ADAPTER::Manager ( ) const

Definition at line 751 of file library_manager.cpp.

References m_manager.

◆ plugin()

virtual IO_BASE * LIBRARY_MANAGER_ADAPTER::plugin ( const LIB_DATA * aRow)
protectedpure virtual

◆ ProjectChanged()

void LIBRARY_MANAGER_ADAPTER::ProjectChanged ( )
virtual

Notify the adapter that the active project has changed.

Definition at line 757 of file library_manager.cpp.

References abortLoad(), m_libraries, and m_libraries_mutex.

◆ ProjectTable()

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 831 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().

◆ ReloadLibraryEntry()

void LIBRARY_MANAGER_ADAPTER::ReloadLibraryEntry ( const wxString & aNickname,
LIBRARY_TABLE_SCOPE aScope = LIBRARY_TABLE_SCOPE::BOTH )

◆ Rows()

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 903 of file library_manager.cpp.

References m_manager, and Type().

Referenced by CVPCB_MAINFRAME::LoadFootprintFiles(), and Type().

◆ ShowConfigurationDialog()

virtual void LIBRARY_MANAGER_ADAPTER::ShowConfigurationDialog ( const wxString & aNickname,
wxWindow * aParent ) const
inlinevirtual

Reimplemented in SYMBOL_LIBRARY_ADAPTER.

Definition at line 162 of file library_manager.h.

Referenced by LIB_TABLE_GRID_TRICKS::onGridCellLeftClick().

◆ SupportsConfigurationDialog()

virtual bool LIBRARY_MANAGER_ADAPTER::SupportsConfigurationDialog ( const wxString & aNickname) const
inlinevirtual

Reimplemented in SYMBOL_LIBRARY_ADAPTER.

Definition at line 160 of file library_manager.h.

Referenced by LIB_TABLE_GRID_TRICKS::onGridCellLeftClick().

◆ Type()

Member Data Documentation

◆ m_abort

std::atomic_bool LIBRARY_MANAGER_ADAPTER::m_abort
protected

Definition at line 203 of file library_manager.h.

Referenced by abortLoad().

◆ m_futures

std::vector<std::future<void> > LIBRARY_MANAGER_ADAPTER::m_futures
protected

◆ m_libraries

◆ m_libraries_mutex

std::mutex LIBRARY_MANAGER_ADAPTER::m_libraries_mutex
protected

◆ m_loadCount

std::atomic<size_t> LIBRARY_MANAGER_ADAPTER::m_loadCount
protected

◆ m_loadTotal

◆ m_manager


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