38#include <wx/textfile.h>
39#include <wx/txtstrm.h>
40#include <wx/wfstream.h>
50 if( footprint ==
nullptr )
82 m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
85 catch(
const std::exception& se )
95 m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
110 long long int generatedTimestamp = 0;
172 size_t num_elements =
m_queue.size();
173 std::vector<std::future<size_t>> returns( num_elements );
176 [
this, &queue_parsed ]() ->
size_t
183 std::vector<wxString> fpnames;
188 fpnames =
m_adapter->GetFootprintNames( nickname );
191 for( wxString fpname : fpnames )
197 queue_parsed.
move_push( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
210 for(
size_t ii = 0; ii < num_elements; ++ii )
211 returns[ii] =
tp.submit_task( fp_thread );
213 for(
const std::future<size_t>& ret : returns )
215 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
217 while( status != std::future_status::ready )
222 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
226 std::unique_ptr<FOOTPRINT_INFO> fpi;
228 while( queue_parsed.
pop( fpi ) )
229 m_list.push_back( std::move( fpi ) );
232 []( std::unique_ptr<FOOTPRINT_INFO>
const& lhs,
233 std::unique_ptr<FOOTPRINT_INFO>
const& rhs ) ->
bool
253 wxFileName tmpFileName = wxFileName::CreateTempFileName( aFilePath );
254 wxFFileOutputStream outStream( tmpFileName.GetFullPath() );
255 wxTextOutputStream txtStream( outStream );
257 if( !outStream.IsOk() )
264 for( std::unique_ptr<FOOTPRINT_INFO>& fpinfo :
m_list )
266 txtStream << fpinfo->GetLibNickname() << endl;
267 txtStream << fpinfo->GetName() << endl;
270 txtStream << wxString::Format( wxT(
"%d" ), fpinfo->GetOrderNum() ) << endl;
271 txtStream << wxString::Format( wxT(
"%u" ), fpinfo->GetPadCount() ) << endl;
272 txtStream << wxString::Format( wxT(
"%u" ), fpinfo->GetUniquePadCount() ) << endl;
281 if( !wxRenameFile( tmpFileName.GetFullPath(), aFilePath,
true ) )
285 wxRemoveFile( tmpFileName.GetFullPath() );
292 wxTextFile cacheFile( aFilePath );
299 if( cacheFile.Exists() && cacheFile.Open() )
303 while( cacheFile.GetCurrentLine() + 6 < cacheFile.GetLineCount() )
305 wxString libNickname = cacheFile.GetNextLine();
306 wxString
name = cacheFile.GetNextLine();
309 int orderNum = wxAtoi( cacheFile.GetNextLine() );
310 unsigned int padCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
311 unsigned int uniquePadCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
315 padCount, uniquePadCount );
317 m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
331 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.