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
 

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)
 Constructs a loader for symbol libraries. More...
 
 ~SYMBOL_ASYNC_LOADER ()
 
void Start ()
 Spins up threads to load all the libraries in m_nicknames. More...
 
bool Join ()
 Finalizes the threads and combines the output into the target output map. More...
 
bool Done ()
 Returns a string containing any errors generated during the load. More...
 
const wxString & GetErrors () const
 Represents a pair of <nickname, loaded parts list> More...
 

Private Member Functions

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

Private Attributes

std::vector< wxString > m_nicknames
 Handle to the symbol library table being loaded into. More...
 
SYMBOL_LIB_TABLEm_table
 True if we are loading only power symbols. More...
 
bool m_onlyPowerSymbols
 Handle to map that will be filled with the loaded parts per library. More...
 
std::unordered_map< wxString, std::vector< LIB_SYMBOL * > > * m_output
 Progress reporter (may be null) More...
 
PROGRESS_REPORTERm_reporter
 
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

Definition at line 72 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 
)

Constructs 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 repord 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 ( )

Returns a string containing any errors generated during the load.

Definition at line 90 of file symbol_async_loader.cpp.

References m_nextLibrary, and m_nicknames.

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

◆ GetErrors()

const wxString & SYMBOL_ASYNC_LOADER::GetErrors ( ) const
inline

Represents a pair of <nickname, loaded parts list>

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

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

Return true if loading is done

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

Spins 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>

list of libraries to load

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 96 of file symbol_async_loader.h.

Referenced by worker().

◆ m_errors

wxString SYMBOL_ASYNC_LOADER::m_errors
private

Definition at line 95 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 94 of file symbol_async_loader.h.

Referenced by Done(), and worker().

◆ m_nicknames

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

Handle to the symbol library table being loaded into.

Definition at line 79 of file symbol_async_loader.h.

Referenced by Done(), and worker().

◆ m_onlyPowerSymbols

bool SYMBOL_ASYNC_LOADER::m_onlyPowerSymbols
private

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

Definition at line 85 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

Progress reporter (may be null)

Definition at line 88 of file symbol_async_loader.h.

Referenced by Join().

◆ m_reporter

PROGRESS_REPORTER* SYMBOL_ASYNC_LOADER::m_reporter
private

Definition at line 91 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 98 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

True if we are loading only power symbols.

Definition at line 82 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 93 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: