39#include <wx/textfile.h>
40#include <wx/txtstrm.h>
41#include <wx/wfstream.h>
52 if( footprint ==
nullptr )
87 catch(
const std::exception& se )
110 long long int generatedTimestamp = 0;
183 std::vector<std::future<size_t>> returns( num_returns );
208 for(
size_t ii = 0; ii < num_returns; ++ii )
209 returns[ii] =
tp.submit( loader_job );
211 for(
const std::future<size_t>& ret : returns )
213 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
215 while( status != std::future_status::ready )
220 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
240 std::vector<std::future<size_t>> returns( num_elements );
243 [
this, &queue_parsed ]() ->
size_t
250 wxArrayString fpnames;
258 for( wxString fpname : fpnames )
264 queue_parsed.
move_push( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
277 for(
size_t ii = 0; ii < num_elements; ++ii )
278 returns[ii] =
tp.submit( fp_thread );
280 for(
const std::future<size_t>& ret : returns )
282 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
284 while( status != std::future_status::ready )
289 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
293 std::unique_ptr<FOOTPRINT_INFO> fpi;
295 while( queue_parsed.
pop( fpi ) )
296 m_list.push_back( std::move( fpi ) );
299 []( std::unique_ptr<FOOTPRINT_INFO>
const& lhs,
300 std::unique_ptr<FOOTPRINT_INFO>
const& rhs ) ->
bool
308 m_list_timestamp( 0 ),
309 m_progress_reporter( nullptr ),
317 wxFileName tmpFileName = wxFileName::CreateTempFileName( aFilePath );
318 wxFFileOutputStream outStream( tmpFileName.GetFullPath() );
319 wxTextOutputStream txtStream( outStream );
321 if( !outStream.IsOk() )
328 for( std::unique_ptr<FOOTPRINT_INFO>& fpinfo :
m_list )
330 txtStream << fpinfo->GetLibNickname() << endl;
331 txtStream << fpinfo->GetName() << endl;
334 txtStream << wxString::Format( wxT(
"%d" ), fpinfo->GetOrderNum() ) << endl;
335 txtStream << wxString::Format( wxT(
"%u" ), fpinfo->GetPadCount() ) << endl;
336 txtStream << wxString::Format( wxT(
"%u" ), fpinfo->GetUniquePadCount() ) << endl;
345 if( !wxRenameFile( tmpFileName.GetFullPath(), aFilePath,
true ) )
349 wxRemoveFile( tmpFileName.GetFullPath() );
356 wxTextFile cacheFile( aFilePath );
363 if( cacheFile.Exists() && cacheFile.Open() )
367 while( cacheFile.GetCurrentLine() + 6 < cacheFile.GetLineCount() )
369 wxString libNickname = cacheFile.GetNextLine();
370 wxString
name = cacheFile.GetNextLine();
373 int orderNum = wxAtoi( cacheFile.GetNextLine() );
374 unsigned int padCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
375 unsigned int uniquePadCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
379 padCount, uniquePadCount );
381 m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
395 if( cacheFile.IsOpened() )
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname, bool aBestEfforts)
Return a list of footprint names contained within the library given by aNickname.
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aNickname, const wxString &aFootprintName)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
long long GenerateTimestamp(const wxString *aNickname)
Generate a hashed timestamp representing the last-mod-times of the library indicated by aNickname,...
void PrefetchLib(const wxString &aNickname)
If possible, prefetches the specified library (e.g.
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)
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
BS::thread_pool thread_pool
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
Definition of file extensions used in Kicad.