KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SYMBOL_ASYNC_LOADER Class Reference

#include <symbol_async_loader.h>

Public Types

typedef std::pair< wxString, std::vector< LIB_SYMBOL * > > LOADED_PAIR
 Represent a pair of <nickname, loaded parts list>.
 

Public Member Functions

 SYMBOL_ASYNC_LOADER (const std::vector< wxString > &aNicknames, SYMBOL_LIB_TABLE *aTable, bool aOnlyPowerSymbols=false, std::unordered_map< wxString, std::vector< LIB_SYMBOL * > > *aOutput=nullptr, PROGRESS_REPORTER *aReporter=nullptr)
 Construct a loader for symbol libraries.
 
 ~SYMBOL_ASYNC_LOADER ()
 
void Start ()
 Spin up threads to load all the libraries in m_nicknames.
 
bool Join ()
 Finalize the threads and combines the output into the target output map.
 
bool Done ()
 
const wxString & GetErrors () const
 

Private Member Functions

std::vector< LOADED_PAIRworker ()
 Worker job that loads libraries and returns a list of pairs of <nickname, loaded parts>.
 

Private Attributes

std::vector< wxString > m_nicknames
 List of libraries to load.
 
SYMBOL_LIB_TABLEm_table
 Handle to the symbol library table being loaded into.
 
bool m_onlyPowerSymbols
 True if we are loading only power symbols.
 
std::unordered_map< wxString, std::vector< LIB_SYMBOL * > > * m_output
 Handle to map that will be filled with the loaded parts per library.
 
PROGRESS_REPORTERm_reporter
 Progress reporter (may be null).
 
size_t m_threadCount
 
std::atomic< size_t > m_nextLibrary
 
wxString m_errors
 
std::mutex m_errorMutex
 
std::vector< std::future< std::vector< LOADED_PAIR > > > m_returns
 

Detailed Description

Definition at line 37 of file symbol_async_loader.h.

Member Typedef Documentation

◆ LOADED_PAIR

typedef std::pair<wxString, std::vector<LIB_SYMBOL*> > SYMBOL_ASYNC_LOADER::LOADED_PAIR

Represent a pair of <nickname, loaded parts list>.

Definition at line 73 of file symbol_async_loader.h.

Constructor & Destructor Documentation

◆ SYMBOL_ASYNC_LOADER()

SYMBOL_ASYNC_LOADER::SYMBOL_ASYNC_LOADER ( const std::vector< wxString > &  aNicknames,
SYMBOL_LIB_TABLE aTable,
bool  aOnlyPowerSymbols = false,
std::unordered_map< wxString, std::vector< LIB_SYMBOL * > > *  aOutput = nullptr,
PROGRESS_REPORTER aReporter = nullptr 
)

Construct a loader for symbol libraries.

Parameters
aNicknamesis a list of library nicknames to load.
aTableis a pointer to the symbol library table to load libraries for.
aOnlyPowerSymbols,iftrue, will only return power symbols in the output map.
aOutputwill be filled with the loaded parts.
aReporterwill be used to report progress, of not null.

Definition at line 29 of file symbol_async_loader.cpp.

References m_returns, m_table, and m_threadCount.

◆ ~SYMBOL_ASYNC_LOADER()

SYMBOL_ASYNC_LOADER::~SYMBOL_ASYNC_LOADER ( )

Definition at line 48 of file symbol_async_loader.cpp.

References Join().

Member Function Documentation

◆ Done()

bool SYMBOL_ASYNC_LOADER::Done ( )

◆ GetErrors()

const wxString & SYMBOL_ASYNC_LOADER::GetErrors ( ) const
inline
Returns
a string containing any errors generated during the load.

Definition at line 70 of file symbol_async_loader.h.

References m_errors.

Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_VIEWER_FRAME::loadAllLibraries(), and SYMBOL_LIBRARY_MANAGER::Preload().

◆ Join()

bool SYMBOL_ASYNC_LOADER::Join ( )

Finalize the threads and combines the output into the target output map.

Definition at line 61 of file symbol_async_loader.cpp.

References m_onlyPowerSymbols, m_output, m_returns, and m_threadCount.

Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_VIEWER_FRAME::loadAllLibraries(), SYMBOL_LIBRARY_MANAGER::Preload(), and ~SYMBOL_ASYNC_LOADER().

◆ Start()

void SYMBOL_ASYNC_LOADER::Start ( )

Spin up threads to load all the libraries in m_nicknames.

Definition at line 54 of file symbol_async_loader.cpp.

References m_returns, m_threadCount, and worker().

Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_VIEWER_FRAME::loadAllLibraries(), and SYMBOL_LIBRARY_MANAGER::Preload().

◆ worker()

std::vector< SYMBOL_ASYNC_LOADER::LOADED_PAIR > SYMBOL_ASYNC_LOADER::worker ( )
private

Worker job that loads libraries and returns a list of pairs of <nickname, loaded parts>.

Definition at line 96 of file symbol_async_loader.cpp.

References _, PROGRESS_REPORTER::AdvancePhase(), PROGRESS_REPORTER::IsCancelled(), SYMBOL_LIB_TABLE::LoadSymbolLib(), m_errorMutex, m_errors, m_nextLibrary, m_nicknames, m_onlyPowerSymbols, m_reporter, m_table, and IO_ERROR::What().

Referenced by Start().

Member Data Documentation

◆ m_errorMutex

std::mutex SYMBOL_ASYNC_LOADER::m_errorMutex
private

Definition at line 97 of file symbol_async_loader.h.

Referenced by worker().

◆ m_errors

wxString SYMBOL_ASYNC_LOADER::m_errors
private

Definition at line 96 of file symbol_async_loader.h.

Referenced by GetErrors(), and worker().

◆ m_nextLibrary

std::atomic<size_t> SYMBOL_ASYNC_LOADER::m_nextLibrary
private

Definition at line 95 of file symbol_async_loader.h.

Referenced by Done(), and worker().

◆ m_nicknames

std::vector<wxString> SYMBOL_ASYNC_LOADER::m_nicknames
private

List of libraries to load.

Definition at line 80 of file symbol_async_loader.h.

Referenced by Done(), and worker().

◆ m_onlyPowerSymbols

bool SYMBOL_ASYNC_LOADER::m_onlyPowerSymbols
private

True if we are loading only power symbols.

Definition at line 86 of file symbol_async_loader.h.

Referenced by Join(), and worker().

◆ m_output

std::unordered_map<wxString, std::vector<LIB_SYMBOL*> >* SYMBOL_ASYNC_LOADER::m_output
private

Handle to map that will be filled with the loaded parts per library.

Definition at line 89 of file symbol_async_loader.h.

Referenced by Join().

◆ m_reporter

PROGRESS_REPORTER* SYMBOL_ASYNC_LOADER::m_reporter
private

Progress reporter (may be null).

Definition at line 92 of file symbol_async_loader.h.

Referenced by worker().

◆ m_returns

std::vector<std::future<std::vector<LOADED_PAIR> > > SYMBOL_ASYNC_LOADER::m_returns
private

Definition at line 99 of file symbol_async_loader.h.

Referenced by Join(), Start(), and SYMBOL_ASYNC_LOADER().

◆ m_table

SYMBOL_LIB_TABLE* SYMBOL_ASYNC_LOADER::m_table
private

Handle to the symbol library table being loaded into.

Definition at line 83 of file symbol_async_loader.h.

Referenced by SYMBOL_ASYNC_LOADER(), and worker().

◆ m_threadCount

size_t SYMBOL_ASYNC_LOADER::m_threadCount
private

Definition at line 94 of file symbol_async_loader.h.

Referenced by Join(), Start(), and SYMBOL_ASYNC_LOADER().


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