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_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.
 
void ProjectTablesChanged (std::initializer_list< LIBRARY_TABLE_TYPE > aChangedTables={})
 Notify the adapter that the project library tables are about to be rebuilt.
 
void ProjectTablesReloaded (std::initializer_list< LIBRARY_TABLE_TYPE > aChangedTables={})
 Complements ProjectTablesChanged by erasing project-scope cache entries whose nicknames no longer appear in the rebuilt project table.
 
void CheckTableRow (LIBRARY_TABLE_ROW &aRow)
 
void AsyncLoad ()
 Loads all available libraries for this adapter type in the background.
 
virtual std::optional< LIB_STATUS > LoadOne (LIB_DATA *aLib)=0
 
virtual std::optional< LIB_STATUS > CheckLibrary (LIB_DATA *aLib)
 Validates that a library is loadable. May not necessarily load the library!
 
std::optional< float > AsyncLoadProgress () const
 Returns the fraction of the libraries queued by AsyncLoad() that have been processed, or nullopt when there is nothing to report (no load has been requested since the last reset, or every library was already loaded).
 
void BlockUntilLoaded ()
 
void AbortAsyncLoad ()
 Aborts any async load in progress; blocks until fully done aborting.
 
bool IsLibraryLoaded (const wxString &aNickname)
 
std::optional< LIB_STATUS > GetLibraryStatus (const wxString &aNickname) const
 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)
 
std::vector< KI_ERROR > GetLibraryLoadErrors () const
 Returns all library load errors as newline-separated strings for display.
 
void ReloadLibraryEntry (const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH)
 Synchronously recreates the plugin for and reloads the given library.
 
std::optional< LIB_STATUS > LoadLibraryEntry (const wxString &aNickname)
 Synchronously loads the named library to LOADED state.
 
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 int ShowConfigurationDialog (const wxString &aNickname, wxWindow *aParent) const
 
virtual std::optional< LIBRARY_ERROR > LibraryError (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::shared_mutex & globalLibsMutex ()=0
 
virtual std::shared_mutex & globalLibsMutex () const =0
 
virtual void enumerateLibrary (LIB_DATA *aLib, const wxString &aUri)=0
 Override in derived class to perform library-specific enumeration.
 
wxString getUri (const LIBRARY_TABLE_ROW *aRow) const
 
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::shared_mutex &aMutex)
 
void evictOwnedGlobalEntries ()
 Erases this adapter's own entries (LIB_DATA::global_owner == this) from the process-wide globalLibs() cache.
 
void abortLoad ()
 Aborts any async load in progress; blocks until fully done aborting.
 
void resetProjectCache ()
 Aborts pending loads and resets every project-scope cache entry in place (plugin and row cleared, status returned to INVALID) while preserving the nickname keys.
 
virtual LIBRARY_RESULT< IO_BASE * > createPlugin (const LIBRARY_TABLE_ROW *row)=0
 Creates a concrete plugin for the given row.
 
virtual IO_BASE * plugin (const LIB_DATA *aRow)=0
 

Static Protected Member Functions

static std::recursive_mutex & pluginMutex (const wxString &aNickname)
 Serializes access to a library's shared plugin instance so its single mutable cache is not raced by concurrent enumerate/load/save/delete calls from the loader pool, preview panels and tree refreshes.
 

Protected Attributes

LIBRARY_MANAGER & m_manager
 
std::map< wxString, LIB_DATA > m_libraries
 
std::shared_mutex m_librariesMutex
 
std::atomic_bool m_abort
 
std::vector< std::future< void > > m_futures
 
std::atomic< size_t > m_loadCount { 0 }
 
std::atomic< size_t > m_loadTotal { 0 }
 
std::mutex m_loadMutex
 

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

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

Member Function Documentation

◆ AbortAsyncLoad()

void LIBRARY_MANAGER_ADAPTER::AbortAsyncLoad ( )

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

This is the public interface to allow LIBRARY_MANAGER to abort loads before project changes.

Definition at line 1153 of file library_manager.cpp.

References abortLoad().

Referenced by PGM_BASE::PreloadDesignBlockLibraries(), PCB::IFACE::PreloadLibraries(), SCH::IFACE::PreloadLibraries(), ReconcileLegacyCacheSymbols(), and SCH_SCREEN::UpdateSymbolLinks().

◆ abortLoad()

void LIBRARY_MANAGER_ADAPTER::abortLoad ( )
protected

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

Definition at line 1429 of file library_manager.cpp.

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

Referenced by AbortAsyncLoad(), CheckTableRow(), enumerateLibrary(), evictOwnedGlobalEntries(), GlobalTablesChanged(), ReloadLibraryEntry(), and resetProjectCache().

◆ AsyncLoad()

◆ AsyncLoadProgress()

std::optional< float > LIBRARY_MANAGER_ADAPTER::AsyncLoadProgress ( ) const

Returns the fraction of the libraries queued by AsyncLoad() that have been processed, or nullopt when there is nothing to report (no load has been requested since the last reset, or every library was already loaded).

This is the non-blocking view of the load: anything other than 1.0 means a load may still be running. It reaches 1.0 once the last library has been counted, which can be a moment before the workers retire, so a path that must not stall still waits with BlockUntilLoaded().

Definition at line 1454 of file library_manager.cpp.

References m_loadCount, and m_loadTotal.

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

◆ BlockUntilLoaded()

◆ CheckLibrary()

virtual std::optional< LIB_STATUS > LIBRARY_MANAGER_ADAPTER::CheckLibrary ( LIB_DATA * aLib)
inlinevirtual

Validates that a library is loadable. May not necessarily load the library!

Reimplemented in SYMBOL_LIBRARY_ADAPTER.

Definition at line 162 of file library_manager.h.

References LoadOne().

Referenced by CheckTableRow().

◆ CheckTableRow()

◆ CreateLibrary()

bool LIBRARY_MANAGER_ADAPTER::CreateLibrary ( const wxString & aNickname)

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

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

Referenced by Type().

◆ enumerateLibrary()

virtual void LIBRARY_MANAGER_ADAPTER::enumerateLibrary ( LIB_DATA * aLib,
const wxString & aUri )
protectedpure virtual

Override in derived class to perform library-specific enumeration.

Parameters
aLib
aUriis the pre-resolved library URI (must be resolved on the main thread since URI expansion accesses PROJECT data that is not thread-safe).

Implemented in DESIGN_BLOCK_LIBRARY_ADAPTER, FOOTPRINT_LIBRARY_ADAPTER, and SYMBOL_LIBRARY_ADAPTER.

References abortLoad(), evictOwnedGlobalEntries(), fetchIfLoaded(), getUri(), loadFromScope(), loadIfNeeded(), and resetProjectCache().

◆ evictOwnedGlobalEntries()

void LIBRARY_MANAGER_ADAPTER::evictOwnedGlobalEntries ( )
protected

Erases this adapter's own entries (LIB_DATA::global_owner == this) from the process-wide globalLibs() cache.

The cached LIB_DATA::row pointers reference this manager's tables, so they must be dropped before the manager is destroyed or a later manager's fetchIfLoaded() would dereference freed rows. Derived destructors must call this while globalLibs() is still resolvable.

Definition at line 1184 of file library_manager.cpp.

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

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

◆ fetchIfLoaded() [1/2]

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

◆ fetchIfLoaded() [2/2]

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

Definition at line 1702 of file library_manager.cpp.

References find, globalLibs(), globalLibsMutex(), LOADED, m_libraries, m_librariesMutex, m_manager, PROJECT, and Type().

Referenced by CheckTableRow(), DESIGN_BLOCK_LIBRARY_ADAPTER::DeleteDesignBlock(), FOOTPRINT_LIBRARY_ADAPTER::DeleteFootprint(), DESIGN_BLOCK_LIBRARY_ADAPTER::DesignBlockExists(), enumerateLibrary(), FOOTPRINT_LIBRARY_ADAPTER::FootprintExists(), FOOTPRINT_LIBRARY_ADAPTER::GenerateTimestamp(), SYMBOL_LIBRARY_ADAPTER::GetAvailableExtraFields(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetDesignBlockNames(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetDesignBlocks(), DESIGN_BLOCK_LIBRARY_ADAPTER::GetEnumeratedDesignBlock(), FOOTPRINT_LIBRARY_ADAPTER::GetFootprintNames(), GetLibraryDescription(), SYMBOL_LIBRARY_ADAPTER::GetLibraryModifyHash(), GetLibraryNames(), SYMBOL_LIBRARY_ADAPTER::GetModifyHash(), SYMBOL_LIBRARY_ADAPTER::GetSubLibraries(), SYMBOL_LIBRARY_ADAPTER::GetSymbolNames(), SYMBOL_LIBRARY_ADAPTER::GetSymbols(), HasLibrary(), DESIGN_BLOCK_LIBRARY_ADAPTER::IsDesignBlockLibWritable(), FOOTPRINT_LIBRARY_ADAPTER::IsFootprintLibWritable(), SYMBOL_LIBRARY_ADAPTER::IsSymbolLibWritable(), IsWritable(), DESIGN_BLOCK_LIBRARY_ADAPTER::LoadDesignBlock(), FOOTPRINT_LIBRARY_ADAPTER::LoadFootprint(), SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), FOOTPRINT_LIBRARY_ADAPTER::RefreshLibraryIfChanged(), DESIGN_BLOCK_LIBRARY_ADAPTER::SaveDesignBlock(), FOOTPRINT_LIBRARY_ADAPTER::SaveFootprint(), SYMBOL_LIBRARY_ADAPTER::ShowConfigurationDialog(), SYMBOL_LIBRARY_ADAPTER::SupportsConfigurationDialog(), and SYMBOL_LIBRARY_ADAPTER::SupportsSubLibraries().

◆ FindLibraryByURI()

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

◆ 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 1421 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

◆ GetLibraryLoadErrors()

std::vector< KI_ERROR > LIBRARY_MANAGER_ADAPTER::GetLibraryLoadErrors ( ) const

Returns all library load errors as newline-separated strings for display.

Definition at line 1551 of file library_manager.cpp.

References _, GetLibraryStatuses(), LOAD_ERROR, and RPT_SEVERITY_ERROR.

Referenced by PCB_EDIT_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::KiwayMailIn(), PCB::IFACE::PreloadLibraries(), and SCH::IFACE::PreloadLibraries().

◆ GetLibraryNames()

◆ GetLibraryStatus()

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

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

References GetLibraryStatus(), INVALID, m_manager, result, and Type().

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

◆ GetRow()

std::optional< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER_ADAPTER::GetRow ( const wxString & aNickname,
LIBRARY_TABLE_SCOPE aScope = LIBRARY_TABLE_SCOPE::BOTH ) const

◆ getUri()

◆ globalLibs() [1/2]

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

◆ globalLibs() [2/2]

◆ globalLibsMutex() [1/2]

virtual std::shared_mutex & LIBRARY_MANAGER_ADAPTER::globalLibsMutex ( ) const
protectedpure virtual

◆ globalLibsMutex() [2/2]

◆ GlobalTable()

LIBRARY_TABLE * LIBRARY_MANAGER_ADAPTER::GlobalTable ( ) const

Retrieves the global library table for this adapter type.

Definition at line 1314 of file library_manager.cpp.

References GLOBAL, m_manager, and Type().

Referenced by 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 1159 of file library_manager.cpp.

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

Referenced by Type().

◆ HasLibrary()

◆ IsLibraryLoaded()

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

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

◆ LibraryError()

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

◆ loadFromScope()

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

◆ loadIfNeeded()

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

◆ LoadLibraryEntry()

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

Synchronously loads the named library to LOADED state.

Returns the resulting status, or nullopt if the library is not found in any table.

Definition at line 1575 of file library_manager.cpp.

References loadIfNeeded(), LoadOne(), and result.

Referenced by API_HANDLER_LIBRARIES::handleGetItemsFromLibrary(), API_HANDLER_LIBRARIES::handleGetLibraryItems(), and loadLibrary().

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

References m_manager.

◆ plugin()

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

◆ pluginMutex()

std::recursive_mutex & LIBRARY_MANAGER_ADAPTER::pluginMutex ( const wxString & aNickname)
staticprotected

Serializes access to a library's shared plugin instance so its single mutable cache is not raced by concurrent enumerate/load/save/delete calls from the loader pool, preview panels and tree refreshes.

Keyed by nickname, a safe over-approximation of the real resource (the plugin instance): sharing one mutex across two distinct resources can only over-serialize, never under-protect. Static because global-library plugins are shared process-wide. Recursive because database/http libraries resolve references back through the adapter into other plugins' LoadSymbol paths while already holding their own mutex.

Definition at line 53 of file library_manager.cpp.

Referenced by SYMBOL_LIBRARY_ADAPTER::CheckLibrary(), CreateLibrary(), FOOTPRINT_LIBRARY_ADAPTER::DeleteFootprint(), DeleteLibrary(), SYMBOL_LIBRARY_ADAPTER::DeleteSymbol(), DESIGN_BLOCK_LIBRARY_ADAPTER::DesignBlockExists(), FOOTPRINT_LIBRARY_ADAPTER::enumerateLibrary(), SYMBOL_LIBRARY_ADAPTER::enumerateLibrary(), FOOTPRINT_LIBRARY_ADAPTER::FootprintExists(), FOOTPRINT_LIBRARY_ADAPTER::GetFootprintNames(), SYMBOL_LIBRARY_ADAPTER::GetSymbolNames(), SYMBOL_LIBRARY_ADAPTER::GetSymbols(), FOOTPRINT_LIBRARY_ADAPTER::IsFootprintLibWritable(), IsWritable(), DESIGN_BLOCK_LIBRARY_ADAPTER::LoadDesignBlock(), FOOTPRINT_LIBRARY_ADAPTER::LoadFootprint(), SYMBOL_LIBRARY_ADAPTER::LoadOne(), SYMBOL_LIBRARY_ADAPTER::LoadSymbol(), plugin(), FOOTPRINT_LIBRARY_ADAPTER::SaveFootprint(), and SYMBOL_LIBRARY_ADAPTER::SaveSymbol().

◆ ProjectChanged()

void LIBRARY_MANAGER_ADAPTER::ProjectChanged ( )
virtual

Notify the adapter that the active project has changed.

Definition at line 1130 of file library_manager.cpp.

References resetProjectCache().

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

References m_manager, PROJECT, and Type().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), SCH_IO_EAGLE::LoadSchematicFile(), SCH_EDIT_FRAME::LoadSheetFromFile(), SCH_EDIT_FRAME::OpenProjectFiles(), and Type().

◆ ProjectTablesChanged()

void LIBRARY_MANAGER_ADAPTER::ProjectTablesChanged ( std::initializer_list< LIBRARY_TABLE_TYPE > aChangedTables = {})

Notify the adapter that the project library tables are about to be rebuilt.

Mirrors GlobalTablesChanged: aborts any in-progress loads and invalidates cached LIB_DATA entries so raw LIBRARY_TABLE_ROW pointers do not dangle when the backing LIBRARY_TABLE objects are destroyed and rebuilt. Entries are reset in place (rather than erased) so their nicknames continue to mask same-named global libraries until the project scope is repopulated.

Definition at line 1202 of file library_manager.cpp.

References resetProjectCache(), and Type().

◆ ProjectTablesReloaded()

void LIBRARY_MANAGER_ADAPTER::ProjectTablesReloaded ( std::initializer_list< LIBRARY_TABLE_TYPE > aChangedTables = {})

Complements ProjectTablesChanged by erasing project-scope cache entries whose nicknames no longer appear in the rebuilt project table.

Must be called AFTER the new project table is loaded; otherwise removed libraries would be permanently masked by stale sentinels installed during the reset.

Definition at line 1222 of file library_manager.cpp.

References m_libraries, m_librariesMutex, m_manager, PROJECT, and Type().

◆ ReloadLibraryEntry()

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

Synchronously recreates the plugin for and reloads the given library.

Definition at line 1586 of file library_manager.cpp.

References abortLoad(), BOTH, GLOBAL, globalLibs(), globalLibsMutex(), loadFromScope(), LoadOne(), m_libraries, m_librariesMutex, PROJECT, result, traceLibraries, and UNINITIALIZED.

Referenced by SCH_IO_EAGLE::LoadSchematicFile().

◆ resetProjectCache()

void LIBRARY_MANAGER_ADAPTER::resetProjectCache ( )
protected

Aborts pending loads and resets every project-scope cache entry in place (plugin and row cleared, status returned to INVALID) while preserving the nickname keys.

Keeping the keys acts as a sentinel: fetchIfLoaded() finds the entry, sees it is no longer LOADED, and returns nullopt instead of falling through to globalLibs(), which is what preserves project-over- global shadowing across a project table reload. Shared between ProjectChanged() and ProjectTablesChanged() so both hooks stay in sync.

Definition at line 1136 of file library_manager.cpp.

References abortLoad(), m_libraries, and m_librariesMutex.

Referenced by enumerateLibrary(), ProjectChanged(), and ProjectTablesChanged().

◆ Rows()

std::vector< LIBRARY_TABLE_ROW * > LIBRARY_MANAGER_ADAPTER::Rows ( LIBRARY_TABLE_SCOPE aScope = LIBRARY_TABLE_SCOPE::BOTH,
bool aIncludeInvalid = false ) const

◆ ShowConfigurationDialog()

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

◆ SupportsConfigurationDialog()

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

Reimplemented in SYMBOL_LIBRARY_ADAPTER.

Definition at line 205 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 279 of file library_manager.h.

Referenced by abortLoad().

◆ m_futures

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

Definition at line 280 of file library_manager.h.

Referenced by abortLoad(), AsyncLoad(), and BlockUntilLoaded().

◆ m_libraries

std::map<wxString, LIB_DATA> LIBRARY_MANAGER_ADAPTER::m_libraries
protected

◆ m_librariesMutex

std::shared_mutex LIBRARY_MANAGER_ADAPTER::m_librariesMutex
mutableprotected

◆ m_loadCount

std::atomic<size_t> LIBRARY_MANAGER_ADAPTER::m_loadCount { 0 }
protected

Definition at line 282 of file library_manager.h.

Referenced by abortLoad(), AsyncLoad(), AsyncLoadProgress(), and BlockUntilLoaded().

◆ m_loadMutex

std::mutex LIBRARY_MANAGER_ADAPTER::m_loadMutex
protected

Definition at line 284 of file library_manager.h.

Referenced by abortLoad(), AsyncLoad(), and BlockUntilLoaded().

◆ m_loadTotal

std::atomic<size_t> LIBRARY_MANAGER_ADAPTER::m_loadTotal { 0 }
protected

Definition at line 283 of file library_manager.h.

Referenced by abortLoad(), AsyncLoad(), AsyncLoadProgress(), and BlockUntilLoaded().

◆ m_manager


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