36#include <wx/textfile.h>
37#include <wx/txtstrm.h>
38#include <wx/wfstream.h>
70 catch(
const std::exception& se )
91 const wxString* aNickname,
94 long long int generatedTimestamp = 0;
169 std::vector<std::future<size_t>> returns( num_returns );
194 for(
size_t ii = 0; ii < num_returns; ++ii )
195 returns[ii] =
tp.submit( loader_job );
197 for(
const std::future<size_t>& ret : returns )
199 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
201 while( status != std::future_status::ready )
206 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
226 std::vector<std::future<size_t>> returns( num_elements );
229 [
this, &queue_parsed ]() ->
size_t
236 wxArrayString dbnames;
244 for( wxString dbname : dbnames )
250 queue_parsed.
move_push( std::unique_ptr<DESIGN_BLOCK_INFO>( dbinfo ) );
263 for(
size_t ii = 0; ii < num_elements; ++ii )
264 returns[ii] =
tp.submit( db_thread );
266 for(
const std::future<size_t>& ret : returns )
268 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
270 while( status != std::future_status::ready )
275 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
279 std::unique_ptr<DESIGN_BLOCK_INFO> dbi;
281 while( queue_parsed.
pop( dbi ) )
282 m_list.push_back( std::move( dbi ) );
285 []( std::unique_ptr<DESIGN_BLOCK_INFO>
const& lhs,
286 std::unique_ptr<DESIGN_BLOCK_INFO>
const& rhs ) ->
bool
294 m_list_timestamp( 0 ), m_progress_reporter( nullptr ), m_cancelled( false )
virtual void load() override
lazily load stuff not filled in by constructor. This may throw IO_ERRORS.
DESIGN_BLOCK_LIST * m_owner
provides access to DESIGN_BLOCK_LIB_TABLE
wxString m_nickname
library as known in DESIGN_BLOCK_LIB_TABLE
wxString m_dbname
Module name.
wxString m_keywords
Design block keywords.
wxString m_doc
Design block description.
void PrefetchLib(const wxString &aNickname)
If possible, prefetches the specified library (e.g.
long long GenerateTimestamp(const wxString *aNickname)
Generate a hashed timestamp representing the last-mod-times of the library indicated by aNickname,...
const DESIGN_BLOCK * GetEnumeratedDesignBlock(const wxString &aNickname, const wxString &aDesignBlockName)
A version of DesignBlockLoad() for use after DesignBlockEnumerate() for more efficient cache manageme...
void DesignBlockEnumerate(wxArrayString &aDesignBlockNames, const wxString &aNickname, bool aBestEfforts)
Return a list of design block names contained within the library given by aNickname.
std::atomic_bool m_cancelled
SYNC_QUEUE< wxString > m_queue_in
bool CatchErrors(const std::function< void()> &aFunc)
Call aFunc, pushing any IO_ERRORs and std::exceptions it throws onto m_errors.
SYNC_QUEUE< wxString > m_queue_out
PROGRESS_REPORTER * m_progress_reporter
long long m_list_timestamp
bool ReadDesignBlockFiles(DESIGN_BLOCK_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Read all the design blocks provided by the combination of aTable and aNickname.
DESIGN_BLOCK_LIB_TABLE * GetTable() const
DESIGN_BLOCK_LIB_TABLE * m_lib_table
no ownership
ERRLIST m_errors
some can be PARSE_ERRORs also
const wxString & GetKeywords() const
const wxString & GetLibDescription() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
RAII class to safely set/reset nil KIIDs for use in footprint/symbol loading.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
virtual void AdvanceProgress()=0
Increment the progress bar length (inside the current virtual zone).
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
Synchronized, locking queue.
bool pop(T &aReceiver)
Pop a value if the queue into the provided variable.
bool empty() const
Return true if the queue is empty.
void clear()
Clear the queue.
size_t size() const
Return the size of the queue.
void push(T const &aValue)
Push a value onto the queue.
void move_push(T &&aValue)
Move a value onto the queue.
#define THROW_IO_ERROR(msg)
BS::thread_pool thread_pool
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
Definition of file extensions used in Kicad.