KiCad PCB EDA Suite
FOOTPRINT_LIST_IMPL Class Reference

#include <footprint_info_impl.h>

Inheritance diagram for FOOTPRINT_LIST_IMPL:
FOOTPRINT_LIST

Public Types

typedef std::vector< std::unique_ptr< FOOTPRINT_INFO > > FPILIST
 
typedef SYNC_QUEUE< std::unique_ptr< IO_ERROR > > ERRLIST
 

Public Member Functions

 FOOTPRINT_LIST_IMPL ()
 
virtual ~FOOTPRINT_LIST_IMPL ()
 
void WriteCacheToFile (const wxString &aFilePath) override
 
void ReadCacheFromFile (const wxString &aFilePath) override
 
bool ReadFootprintFiles (FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
 Read all the footprints provided by the combination of aTable and aNickname. More...
 
unsigned GetCount () const
 
const FPILISTGetList () const
 Was forced to add this by modview_frame.cpp. More...
 
void Clear ()
 
FOOTPRINT_INFOGetFootprintInfo (const wxString &aFootprintName)
 Get info for a footprint by id. More...
 
FOOTPRINT_INFOGetFootprintInfo (const wxString &aLibNickname, const wxString &aFootprintName)
 Get info for a footprint by libNickname/footprintName. More...
 
FOOTPRINT_INFOGetItem (unsigned aIdx) const
 Get info for a footprint by index. More...
 
unsigned GetErrorCount () const
 
std::unique_ptr< IO_ERRORPopError ()
 
void DisplayErrors (wxTopLevelWindow *aCaller=nullptr)
 
FP_LIB_TABLEGetTable () const
 

Static Public Member Functions

static FOOTPRINT_LISTGetInstance (KIWAY &aKiway)
 Factory function to return a FOOTPRINT_LIST via Kiway. More...
 

Protected Member Functions

void loadLibs ()
 
void loadFootprints ()
 

Protected Attributes

FP_LIB_TABLEm_lib_table
 no ownership More...
 
FPILIST m_list
 
ERRLIST m_errors
 some can be PARSE_ERRORs also More...
 

Private Member Functions

bool CatchErrors (const std::function< void()> &aFunc)
 Call aFunc, pushing any IO_ERRORs and std::exceptions it throws onto m_errors. More...
 

Private Attributes

SYNC_QUEUE< wxString > m_queue_in
 
SYNC_QUEUE< wxString > m_queue_out
 
long long m_list_timestamp
 
PROGRESS_REPORTERm_progress_reporter
 
std::atomic_bool m_cancelled
 
std::mutex m_join
 

Detailed Description

Definition at line 84 of file footprint_info_impl.h.

Member Typedef Documentation

◆ ERRLIST

typedef SYNC_QUEUE<std::unique_ptr<IO_ERROR> > FOOTPRINT_LIST::ERRLIST
inherited

Definition at line 169 of file footprint_info.h.

◆ FPILIST

typedef std::vector<std::unique_ptr<FOOTPRINT_INFO> > FOOTPRINT_LIST::FPILIST
inherited

Definition at line 168 of file footprint_info.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_LIST_IMPL()

FOOTPRINT_LIST_IMPL::FOOTPRINT_LIST_IMPL ( )

Definition at line 299 of file footprint_info_impl.cpp.

299 :
300 m_list_timestamp( 0 ),
301 m_progress_reporter( nullptr ),
302 m_cancelled( false )
303{
304}
std::atomic_bool m_cancelled
PROGRESS_REPORTER * m_progress_reporter

◆ ~FOOTPRINT_LIST_IMPL()

virtual FOOTPRINT_LIST_IMPL::~FOOTPRINT_LIST_IMPL ( )
inlinevirtual

Definition at line 88 of file footprint_info_impl.h.

88{};

Member Function Documentation

◆ CatchErrors()

bool FOOTPRINT_LIST_IMPL::CatchErrors ( const std::function< void()> &  aFunc)
private

Call aFunc, pushing any IO_ERRORs and std::exceptions it throws onto m_errors.

Returns
true if no error occurred.

Definition at line 67 of file footprint_info_impl.cpp.

68{
69 try
70 {
71 aFunc();
72 }
73 catch( const IO_ERROR& ioe )
74 {
75 m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
76 return false;
77 }
78 catch( const std::exception& se )
79 {
80 // This is a round about way to do this, but who knows what THROW_IO_ERROR()
81 // may be tricked out to do someday, keep it in the game.
82 try
83 {
84 THROW_IO_ERROR( se.what() );
85 }
86 catch( const IO_ERROR& ioe )
87 {
88 m_errors.move_push( std::make_unique<IO_ERROR>( ioe ) );
89 }
90
91 return false;
92 }
93
94 return true;
95}
ERRLIST m_errors
some can be PARSE_ERRORs also
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
void move_push(T &&aValue)
Move a value onto the queue.
Definition: sync_queue.h:50
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References FOOTPRINT_LIST::m_errors, SYNC_QUEUE< T >::move_push(), and THROW_IO_ERROR.

Referenced by loadFootprints(), loadLibs(), and ReadFootprintFiles().

◆ Clear()

void FOOTPRINT_LIST::Clear ( )
inlineinherited
Returns
Clears the footprint info cache

Definition at line 199 of file footprint_info.h.

200 {
201 m_list.clear();
202 }

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ DisplayErrors()

void FOOTPRINT_LIST::DisplayErrors ( wxTopLevelWindow *  aCaller = nullptr)
inherited

Definition at line 93 of file footprint_info.cpp.

94{
95 // @todo: go to a more HTML !<table>! ? centric output, possibly with recommendations
96 // for remedy of errors. Add numeric error codes to PARSE_ERROR, and switch on them for
97 // remedies, etc. Full access is provided to everything in every exception!
98
99 HTML_MESSAGE_BOX dlg( aWindow, _( "Load Error" ) );
100
101 dlg.MessageSet( _( "Errors were encountered loading footprints:" ) );
102
103 wxString msg;
104
105 while( std::unique_ptr<IO_ERROR> error = PopError() )
106 {
107 wxString tmp = error->Problem();
108
109 // Preserve new lines in error messages so queued errors don't run together.
110 tmp.Replace( wxS( "\n" ), wxS( "<BR>" ) );
111 msg += wxT( "<p>" ) + tmp + wxT( "</p>" );
112 }
113
114 dlg.AddHTML_Text( msg );
115
116 dlg.ShowModal();
117}
std::unique_ptr< IO_ERROR > PopError()
#define _(s)

References _, HTML_MESSAGE_BOX::AddHTML_Text(), HTML_MESSAGE_BOX::MessageSet(), and FOOTPRINT_LIST::PopError().

Referenced by FOOTPRINT_EDIT_FRAME::initLibraryTree(), CVPCB_MAINFRAME::LoadFootprintFiles(), and PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ GetCount()

unsigned FOOTPRINT_LIST::GetCount ( ) const
inlineinherited

◆ GetErrorCount()

unsigned FOOTPRINT_LIST::GetErrorCount ( ) const
inlineinherited

Definition at line 226 of file footprint_info.h.

227 {
228 return m_errors.size();
229 }
size_t size() const
Return the size of the queue.
Definition: sync_queue.h:91

Referenced by FOOTPRINT_EDIT_FRAME::initLibraryTree(), CVPCB_MAINFRAME::LoadFootprintFiles(), and PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ GetFootprintInfo() [1/2]

FOOTPRINT_INFO * FOOTPRINT_LIST::GetFootprintInfo ( const wxString &  aFootprintName)
inherited

Get info for a footprint by id.

Definition at line 58 of file footprint_info.cpp.

59{
60 if( aFootprintName.IsEmpty() )
61 return nullptr;
62
63 LIB_ID fpid;
64
65 wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, nullptr,
66 wxString::Format( wxT( "'%s' is not a valid LIB_ID." ), aFootprintName ) );
67
68 return GetFootprintInfo( fpid.GetLibNickname(), fpid.GetLibItemName() );
69}
FOOTPRINT_INFO * GetFootprintInfo(const wxString &aFootprintName)
Get info for a footprint by id.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:50
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format(), FOOTPRINT_LIST::GetFootprintInfo(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), and LIB_ID::Parse().

Referenced by CVPCB_MAINFRAME::AssociateFootprint(), CVPCB_MAINFRAME::AutomaticFootprintMatching(), CVPCB_MAINFRAME::BuildSymbolsListBox(), CVPCB_MAINFRAME::DisplayStatus(), FOOTPRINT_LIST::GetFootprintInfo(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), CVPCB_MAINFRAME::readNetListAndFpFiles(), and PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ GetFootprintInfo() [2/2]

FOOTPRINT_INFO * FOOTPRINT_LIST::GetFootprintInfo ( const wxString &  aLibNickname,
const wxString &  aFootprintName 
)
inherited

Get info for a footprint by libNickname/footprintName.

Definition at line 42 of file footprint_info.cpp.

44{
45 if( aFootprintName.IsEmpty() )
46 return nullptr;
47
48 for( std::unique_ptr<FOOTPRINT_INFO>& fp : m_list )
49 {
50 if( aLibNickname == fp->GetLibNickname() && aFootprintName == fp->GetFootprintName() )
51 return fp.get();
52 }
53
54 return nullptr;
55}

References FOOTPRINT_LIST::m_list.

◆ GetInstance()

FOOTPRINT_LIST * FOOTPRINT_LIST::GetInstance ( KIWAY aKiway)
staticinherited

Factory function to return a FOOTPRINT_LIST via Kiway.

This is not guaranteed to succeed and will return null if the kiface is not available.

Parameters
aKiwayactive kiway instance.

Definition at line 143 of file footprint_info.cpp.

144{
146
147 if( !footprintInfo )
148 return nullptr;
149
150 if( !footprintInfo->GetCount() )
151 footprintInfo->ReadCacheFromFile( aKiway.Prj().GetProjectPath() + wxS( "fp-info-cache" ) );
152
153 return footprintInfo;
154}
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
virtual void ReadCacheFromFile(const wxString &aFilePath)
unsigned GetCount() const
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:192
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
static FOOTPRINT_LIST * get_instance_from_id(KIWAY &aKiway, int aId)
@ KIFACE_FOOTPRINT_LIST
Return a pointer to the global instance of FOOTPRINT_LIST from pcbnew.
Definition: kiface_ids.h:39

References get_instance_from_id(), FOOTPRINT_LIST::GetCount(), PROJECT::GetProjectPath(), KIFACE_FOOTPRINT_LIST, KIWAY::Prj(), and FOOTPRINT_LIST::ReadCacheFromFile().

Referenced by DIALOG_CHOOSE_SYMBOL::ConstructRightPanel(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), FOOTPRINT_SELECT_WIDGET::Load(), and FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList().

◆ GetItem()

FOOTPRINT_INFO & FOOTPRINT_LIST::GetItem ( unsigned  aIdx) const
inlineinherited

Get info for a footprint by index.

Parameters
aIdxindex of the given item.
Returns
the aIdx item in list.

Definition at line 221 of file footprint_info.h.

222 {
223 return *m_list[aIdx];
224 }

Referenced by FOOTPRINT_FILTER::ITERATOR::increment().

◆ GetList()

const FPILIST & FOOTPRINT_LIST::GetList ( ) const
inlineinherited

Was forced to add this by modview_frame.cpp.

Definition at line 191 of file footprint_info.h.

192 {
193 return m_list;
194 }

Referenced by FP_TREE_MODEL_ADAPTER::getFootprints().

◆ GetTable()

FP_LIB_TABLE * FOOTPRINT_LIST::GetTable ( ) const
inlineinherited

Definition at line 256 of file footprint_info.h.

257 {
258 return m_lib_table;
259 }
FP_LIB_TABLE * m_lib_table
no ownership

Referenced by FOOTPRINT_INFO_IMPL::load().

◆ loadFootprints()

void FOOTPRINT_LIST_IMPL::loadFootprints ( )
protected

Definition at line 218 of file footprint_info_impl.cpp.

219{
220 LOCALE_IO toggle_locale;
221
222 // Parse the footprints in parallel. WARNING! This requires changing the locale, which is
223 // GLOBAL. It is only thread safe to construct the LOCALE_IO before the threads are created,
224 // destroy it after they finish, and block the main (GUI) thread while they work. Any deviation
225 // from this will cause nasal demons.
226 //
227 // TODO: blast LOCALE_IO into the sun
228
231 size_t num_elements = m_queue_out.size();
232 std::vector<std::future<size_t>> returns( num_elements );
233
234 auto fp_thread =
235 [ this, &queue_parsed ]() -> size_t
236 {
237 wxString nickname;
238
239 if( m_cancelled || !m_queue_out.pop( nickname ) )
240 return 0;
241
242 wxArrayString fpnames;
243
245 [&]()
246 {
247 m_lib_table->FootprintEnumerate( fpnames, nickname, false );
248 } );
249
250 for( wxString fpname : fpnames )
251 {
253 [&]()
254 {
255 auto* fpinfo = new FOOTPRINT_INFO_IMPL( this, nickname, fpname );
256 queue_parsed.move_push( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
257 } );
258
259 if( m_cancelled )
260 return 0;
261 }
262
265
266 return 1;
267 };
268
269 for( size_t ii = 0; ii < num_elements; ++ii )
270 returns[ii] = tp.submit( fp_thread );
271
272 for( const std::future<size_t>& ret : returns )
273 {
274 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
275
276 while( status != std::future_status::ready )
277 {
280
281 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
282 }
283 }
284
285 std::unique_ptr<FOOTPRINT_INFO> fpi;
286
287 while( queue_parsed.pop( fpi ) )
288 m_list.push_back( std::move( fpi ) );
289
290 std::sort( m_list.begin(), m_list.end(),
291 []( std::unique_ptr<FOOTPRINT_INFO> const& lhs,
292 std::unique_ptr<FOOTPRINT_INFO> const& rhs ) -> bool
293 {
294 return *lhs < *rhs;
295 } );
296}
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
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname, bool aBestEfforts)
Return a list of footprint names contained within the library given by aNickname.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void AdvanceProgress()=0
Increment the progress bar length (inside the current virtual zone).
Synchronized, locking queue.
Definition: sync_queue.h:32
bool pop(T &aReceiver)
Pop a value if the queue into the provided variable.
Definition: sync_queue.h:63
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
Definition: thread_pool.cpp:32
static thread_pool * tp
Definition: thread_pool.cpp:30
BS::thread_pool thread_pool
Definition: thread_pool.h:30

References PROGRESS_REPORTER::AdvanceProgress(), CatchErrors(), FP_LIB_TABLE::FootprintEnumerate(), GetKiCadThreadPool(), PROGRESS_REPORTER::KeepRefreshing(), m_cancelled, FOOTPRINT_LIST::m_lib_table, FOOTPRINT_LIST::m_list, m_progress_reporter, m_queue_out, SYNC_QUEUE< T >::move_push(), SYNC_QUEUE< T >::pop(), SYNC_QUEUE< T >::size(), and tp.

Referenced by ReadFootprintFiles().

◆ loadLibs()

void FOOTPRINT_LIST_IMPL::loadLibs ( )
protected

Definition at line 171 of file footprint_info_impl.cpp.

172{
174 size_t num_returns = m_queue_in.size();
175 std::vector<std::future<size_t>> returns( num_returns );
176
177 auto loader_job =
178 [this]() -> size_t
179 {
180 wxString nickname;
181 size_t retval = 0;
182
183 if( !m_cancelled && m_queue_in.pop( nickname ) )
184 {
185 if( CatchErrors( [this, &nickname]()
186 {
187 m_lib_table->PrefetchLib( nickname );
188 m_queue_out.push( nickname );
189 } ) && m_progress_reporter )
190 {
192 }
193
194 ++retval;
195 }
196
197 return retval;
198 };
199
200 for( size_t ii = 0; ii < num_returns; ++ii )
201 returns[ii] = tp.submit( loader_job );
202
203 for( const std::future<size_t>& ret : returns )
204 {
205 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
206
207 while( status != std::future_status::ready )
208 {
210 m_cancelled = true;
211
212 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
213 }
214 }
215}
SYNC_QUEUE< wxString > m_queue_in
void PrefetchLib(const wxString &aNickname)
If possible, prefetches the specified library (e.g.
void push(T const &aValue)
Push a value onto the queue.
Definition: sync_queue.h:41

References PROGRESS_REPORTER::AdvanceProgress(), CatchErrors(), GetKiCadThreadPool(), PROGRESS_REPORTER::KeepRefreshing(), m_cancelled, FOOTPRINT_LIST::m_lib_table, m_progress_reporter, m_queue_in, m_queue_out, SYNC_QUEUE< T >::pop(), FP_LIB_TABLE::PrefetchLib(), SYNC_QUEUE< T >::push(), SYNC_QUEUE< T >::size(), and tp.

Referenced by ReadFootprintFiles().

◆ PopError()

std::unique_ptr< IO_ERROR > FOOTPRINT_LIST::PopError ( )
inlineinherited

Definition at line 231 of file footprint_info.h.

232 {
233 std::unique_ptr<IO_ERROR> error;
234
235 m_errors.pop( error );
236 return error;
237 }

Referenced by FOOTPRINT_LIST::DisplayErrors().

◆ ReadCacheFromFile()

void FOOTPRINT_LIST_IMPL::ReadCacheFromFile ( const wxString &  aFilePath)
overridevirtual

Reimplemented from FOOTPRINT_LIST.

Definition at line 343 of file footprint_info_impl.cpp.

344{
345 wxTextFile cacheFile( aFilePath );
346
348 m_list.clear();
349
350 try
351 {
352 if( cacheFile.Exists() && cacheFile.Open() )
353 {
354 cacheFile.GetFirstLine().ToLongLong( &m_list_timestamp );
355
356 while( cacheFile.GetCurrentLine() + 6 < cacheFile.GetLineCount() )
357 {
358 wxString libNickname = cacheFile.GetNextLine();
359 wxString name = cacheFile.GetNextLine();
360 wxString desc = UnescapeString( cacheFile.GetNextLine() );
361 wxString keywords = UnescapeString( cacheFile.GetNextLine() );
362 int orderNum = wxAtoi( cacheFile.GetNextLine() );
363 unsigned int padCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
364 unsigned int uniquePadCount = (unsigned) wxAtoi( cacheFile.GetNextLine() );
365
366 FOOTPRINT_INFO_IMPL* fpinfo = new FOOTPRINT_INFO_IMPL( libNickname, name, desc,
367 keywords, orderNum,
368 padCount, uniquePadCount );
369
370 m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
371 }
372 }
373 }
374 catch( ... )
375 {
376 // whatever went wrong, invalidate the cache
378 }
379
380 // Sanity check: an empty list is very unlikely to be correct.
381 if( m_list.size() == 0 )
383
384 if( cacheFile.IsOpened() )
385 cacheFile.Close();
386}
const char * name
Definition: DXF_plotter.cpp:56
wxString UnescapeString(const wxString &aSource)

References FOOTPRINT_LIST::m_list, m_list_timestamp, name, and UnescapeString().

Referenced by FOOTPRINT_EDIT_FRAME::initLibraryTree(), and PCB_EDIT_FRAME::OpenProjectFiles().

◆ ReadFootprintFiles()

bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles ( FP_LIB_TABLE aTable,
const wxString *  aNickname = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
overridevirtual

Read all the footprints provided by the combination of aTable and aNickname.

Parameters
aTabledefines all the libraries.
aNicknameis the library to read from, or if NULL means read all footprints from all known libraries in aTable.
aProgressReporteris an optional progress reporter. ReadFootprintFiles() will use 2 phases within the reporter.
Returns
true if it ran to completion, else false if it aborted after some number of errors. If true, it does not mean there were no errors, check GetErrorCount() for that, should be zero to indicate success.

Implements FOOTPRINT_LIST.

Definition at line 98 of file footprint_info_impl.cpp.

100{
101 long long int generatedTimestamp = 0;
102
103 if( !CatchErrors( [&]()
104 {
105 generatedTimestamp = aTable->GenerateTimestamp( aNickname );
106 } ) )
107 {
108 return false;
109 }
110
111 if( generatedTimestamp == m_list_timestamp )
112 return true;
113
114 // Disable KIID generation: not needed for library parts; sometimes very slow
115 KIID_NIL_SET_RESET reset_kiid;
116
117 m_progress_reporter = aProgressReporter;
118
120 {
122 m_progress_reporter->Report( _( "Fetching footprint libraries..." ) );
123 }
124
125 m_cancelled = false;
126 m_lib_table = aTable;
127
128 // Clear data before reading files
129 m_errors.clear();
130 m_list.clear();
133
134 if( aNickname )
135 {
136 m_queue_in.push( *aNickname );
137 }
138 else
139 {
140 for( const wxString& nickname : aTable->GetLogicalLibs() )
141 m_queue_in.push( nickname );
142 }
143
144
145 loadLibs();
146
147 if( !m_cancelled )
148 {
150 {
153 m_progress_reporter->Report( _( "Loading footprints..." ) );
154 }
155
157
160 }
161
162 if( m_cancelled )
163 m_list_timestamp = 0; // God knows what we got before we were canceled
164 else
165 m_list_timestamp = generatedTimestamp;
166
167 return m_errors.empty();
168}
long long GenerateTimestamp(const wxString *aNickname)
Generate a hashed timestamp representing the last-mod-times of the library indicated by aNickname,...
RAII class to safely set/reset nil KIIDs for use in footprint/symbol loading.
Definition: kiid.h:199
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
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 SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
bool empty() const
Return true if the queue is empty.
Definition: sync_queue.h:82
void clear()
Clear the queue.
Definition: sync_queue.h:100

References _, PROGRESS_REPORTER::AdvancePhase(), CatchErrors(), SYNC_QUEUE< T >::clear(), SYNC_QUEUE< T >::empty(), FP_LIB_TABLE::GenerateTimestamp(), LIB_TABLE::GetLogicalLibs(), loadFootprints(), loadLibs(), m_cancelled, FOOTPRINT_LIST::m_errors, FOOTPRINT_LIST::m_lib_table, FOOTPRINT_LIST::m_list, m_list_timestamp, m_progress_reporter, m_queue_in, m_queue_out, SYNC_QUEUE< T >::push(), PROGRESS_REPORTER::Report(), PROGRESS_REPORTER::SetMaxProgress(), and SYNC_QUEUE< T >::size().

Referenced by FOOTPRINT_EDIT_FRAME::initLibraryTree(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

◆ WriteCacheToFile()

void FOOTPRINT_LIST_IMPL::WriteCacheToFile ( const wxString &  aFilePath)
overridevirtual

Reimplemented from FOOTPRINT_LIST.

Definition at line 307 of file footprint_info_impl.cpp.

308{
309 wxFileName tmpFileName = wxFileName::CreateTempFileName( aFilePath );
310 wxFFileOutputStream outStream( tmpFileName.GetFullPath() );
311 wxTextOutputStream txtStream( outStream );
312
313 if( !outStream.IsOk() )
314 {
315 return;
316 }
317
318 txtStream << wxString::Format( wxT( "%lld" ), m_list_timestamp ) << endl;
319
320 for( std::unique_ptr<FOOTPRINT_INFO>& fpinfo : m_list )
321 {
322 txtStream << fpinfo->GetLibNickname() << endl;
323 txtStream << fpinfo->GetName() << endl;
324 txtStream << EscapeString( fpinfo->GetDescription(), CTX_LINE ) << endl;
325 txtStream << EscapeString( fpinfo->GetKeywords(), CTX_LINE ) << endl;
326 txtStream << wxString::Format( wxT( "%d" ), fpinfo->GetOrderNum() ) << endl;
327 txtStream << wxString::Format( wxT( "%u" ), fpinfo->GetPadCount() ) << endl;
328 txtStream << wxString::Format( wxT( "%u" ), fpinfo->GetUniquePadCount() ) << endl;
329 }
330
331 txtStream.Flush();
332 outStream.Close();
333
334 if( !wxRenameFile( tmpFileName.GetFullPath(), aFilePath, true ) )
335 {
336 // cleanup in case rename failed
337 // its also not the end of the world since this is just a cache file
338 wxRemoveFile( tmpFileName.GetFullPath() );
339 }
340}
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LINE
Definition: string_utils.h:59

References CTX_LINE, EscapeString(), Format(), FOOTPRINT_LIST::m_list, and m_list_timestamp.

Referenced by FOOTPRINT_EDIT_FRAME::doCloseWindow(), and PCB_BASE_EDIT_FRAME::doCloseWindow().

Member Data Documentation

◆ m_cancelled

std::atomic_bool FOOTPRINT_LIST_IMPL::m_cancelled
private

Definition at line 112 of file footprint_info_impl.h.

Referenced by loadFootprints(), loadLibs(), and ReadFootprintFiles().

◆ m_errors

ERRLIST FOOTPRINT_LIST::m_errors
protectedinherited

some can be PARSE_ERRORs also

Definition at line 274 of file footprint_info.h.

Referenced by CatchErrors(), and ReadFootprintFiles().

◆ m_join

std::mutex FOOTPRINT_LIST_IMPL::m_join
private

Definition at line 113 of file footprint_info_impl.h.

◆ m_lib_table

FP_LIB_TABLE* FOOTPRINT_LIST::m_lib_table
protectedinherited

no ownership

Definition at line 271 of file footprint_info.h.

Referenced by loadFootprints(), loadLibs(), and ReadFootprintFiles().

◆ m_list

◆ m_list_timestamp

long long FOOTPRINT_LIST_IMPL::m_list_timestamp
private

Definition at line 110 of file footprint_info_impl.h.

Referenced by ReadCacheFromFile(), ReadFootprintFiles(), and WriteCacheToFile().

◆ m_progress_reporter

PROGRESS_REPORTER* FOOTPRINT_LIST_IMPL::m_progress_reporter
private

Definition at line 111 of file footprint_info_impl.h.

Referenced by loadFootprints(), loadLibs(), and ReadFootprintFiles().

◆ m_queue_in

SYNC_QUEUE<wxString> FOOTPRINT_LIST_IMPL::m_queue_in
private

Definition at line 108 of file footprint_info_impl.h.

Referenced by loadLibs(), and ReadFootprintFiles().

◆ m_queue_out

SYNC_QUEUE<wxString> FOOTPRINT_LIST_IMPL::m_queue_out
private

Definition at line 109 of file footprint_info_impl.h.

Referenced by loadFootprints(), loadLibs(), and ReadFootprintFiles().


The documentation for this class was generated from the following files: