38#include <wx/textfile.h>
39#include <wx/txtstrm.h>
40#include <wx/wfstream.h>
52 if( footprint ==
nullptr )
62 m_doc = footprint->GetLibDescription();
69 m_owner->PushError( std::make_unique<IO_ERROR>( ioe ) );
96 m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
99 catch(
const std::exception& se )
109 m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
124 long long int generatedTimestamp = 0;
186 size_t num_elements =
m_queue.size();
187 std::vector<std::future<size_t>> returns( num_elements );
190 [
this, &queue_parsed ]() ->
size_t
197 std::vector<wxString> fpnames;
202 fpnames =
m_adapter->GetFootprintNames( nickname );
205 for( wxString fpname : fpnames )
211 queue_parsed.
move_push( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
224 for(
size_t ii = 0; ii < num_elements; ++ii )
225 returns[ii] =
tp.submit_task( fp_thread );
227 for(
const std::future<size_t>& ret : returns )
229 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
231 while( status != std::future_status::ready )
236 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
240 std::unique_ptr<FOOTPRINT_INFO> fpi;
242 while( queue_parsed.
pop( fpi ) )
243 m_list.push_back( std::move( fpi ) );
246 []( std::unique_ptr<FOOTPRINT_INFO>
const& lhs,
247 std::unique_ptr<FOOTPRINT_INFO>
const& rhs ) ->
bool
267 wxFileName tmpFileName = wxFileName::CreateTempFileName( aFilePath );
268 wxFFileOutputStream outStream( tmpFileName.GetFullPath() );
269 wxTextOutputStream txtStream( outStream );
271 if( !outStream.IsOk() )
278 for( std::unique_ptr<FOOTPRINT_INFO>& fpinfo :
m_list )
280 txtStream << fpinfo->GetLibNickname() << endl;
281 txtStream << fpinfo->GetName() << endl;
284 txtStream << wxString::Format( wxT(
"%d" ), fpinfo->GetOrderNum() ) << endl;
285 txtStream << wxString::Format( wxT(
"%u" ), fpinfo->GetPadCount() ) << endl;
286 txtStream << wxString::Format( wxT(
"%u" ), fpinfo->GetUniquePadCount() ) << endl;
295 if( !wxRenameFile( tmpFileName.GetFullPath(), aFilePath,
true ) )
299 wxRemoveFile( tmpFileName.GetFullPath() );
306 wxTextFile cacheFile( aFilePath );
313 if( cacheFile.Exists() && cacheFile.Open() )
317 while( cacheFile.GetCurrentLine() + 6 < cacheFile.GetLineCount() )
319 wxString libNickname = cacheFile.GetNextLine();
320 wxString
name = cacheFile.GetNextLine();
323 int orderNum = wxAtoi( cacheFile.GetNextLine() );
324 unsigned int padCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
325 unsigned int uniquePadCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
329 padCount, uniquePadCount );
331 m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
345 if( cacheFile.IsOpened() )
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 > GetLibraryNames() const
Returns a list of library nicknames that are available (skips any that failed to load)
A progress reporter interface for use in multi-threaded environments.
Synchronized, locking queue.
bool pop(T &aReceiver)
Pop a value if the queue into the provided variable.
void move_push(T &&aValue)
Move a value onto the queue.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
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:...
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::priority_thread_pool thread_pool
Definition of file extensions used in Kicad.