33#include <wx/txtstrm.h>
34#include <wx/wfstream.h>
48 m_doc = design_block->GetLibDescription();
66 catch(
const std::exception& se )
87 const wxString* aNickname,
90 long long int generatedTimestamp = 0;
155 std::vector<std::future<size_t>> returns( num_elements );
158 [
this, &queue_parsed ]() ->
size_t
165 wxArrayString dbnames;
173 for( wxString dbname : dbnames )
179 queue_parsed.
move_push( std::unique_ptr<DESIGN_BLOCK_INFO>( dbinfo ) );
192 for(
size_t ii = 0; ii < num_elements; ++ii )
193 returns[ii] =
tp.submit( db_thread );
195 for(
const std::future<size_t>& ret : returns )
197 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
199 while( status != std::future_status::ready )
204 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
208 std::unique_ptr<DESIGN_BLOCK_INFO> dbi;
210 while( queue_parsed.
pop( dbi ) )
211 m_list.push_back( std::move( dbi ) );
214 []( std::unique_ptr<DESIGN_BLOCK_INFO>
const& lhs,
215 std::unique_ptr<DESIGN_BLOCK_INFO>
const& rhs ) ->
bool
223 m_list_timestamp( 0 ),
224 m_progress_reporter( nullptr ),
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.
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
bool CatchErrors(const std::function< void()> &aFunc)
Call aFunc, pushing any IO_ERRORs and std::exceptions it throws onto m_errors.
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.
SYNC_QUEUE< wxString > m_queue
SYNC_QUEUE< std::unique_ptr< IO_ERROR > > m_errors
some can be PARSE_ERRORs also
std::vector< std::unique_ptr< DESIGN_BLOCK_INFO > > m_list
DESIGN_BLOCK_LIB_TABLE * GetTable() const
DESIGN_BLOCK_LIB_TABLE * m_lib_table
no ownership
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.
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)
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::thread_pool thread_pool
Definition of file extensions used in Kicad.