KiCad PCB EDA Suite
Loading...
Searching...
No Matches
FOOTPRINT_LIST_IMPL Class Reference

#include <footprint_info_impl.h>

Inheritance diagram for FOOTPRINT_LIST_IMPL:
FOOTPRINT_LIST

Public Member Functions

 FOOTPRINT_LIST_IMPL ()
 
virtual ~FOOTPRINT_LIST_IMPL ()
 
bool ReadFootprintFiles (FOOTPRINT_LIBRARY_ADAPTER *aAdapter, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
 Read all the footprints provided by the combination of aTable and aNickname.
 
void Clear () override
 
void WithFootprintsForLibrary (const wxString &aLibName, const std::function< void(const std::vector< LIB_TREE_ITEM * > &)> &aCallback)
 Execute a callback with thread-safe access to the footprints for a library.
 
unsigned GetCount () const
 
const std::vector< std::unique_ptr< FOOTPRINT_INFO > > & GetList () const
 Was forced to add this by modview_frame.cpp.
 
FOOTPRINT_INFOGetFootprintInfo (const wxString &aFootprintName)
 Get info for a footprint by id.
 
FOOTPRINT_INFOGetFootprintInfo (const wxString &aLibNickname, const wxString &aFootprintName)
 Get info for a footprint by libNickname/footprintName.
 
FOOTPRINT_INFOGetItem (unsigned aIdx) const
 Get info for a footprint by index.
 
unsigned GetErrorCount () const
 
std::unique_ptr< IO_ERRORPopError ()
 
void PushError (std::unique_ptr< IO_ERROR > aError)
 
void DisplayErrors (wxTopLevelWindow *aCaller=nullptr)
 
wxString GetErrorMessages ()
 Returns all accumulated errors as a newline-separated string for display in the status bar.
 
FOOTPRINT_LIBRARY_ADAPTERGetAdapter () const
 

Protected Member Functions

void loadFootprints ()
 

Protected Attributes

FOOTPRINT_LIBRARY_ADAPTERm_adapter
 no ownership
 
std::vector< std::unique_ptr< FOOTPRINT_INFO > > m_list
 
SYNC_QUEUE< std::unique_ptr< IO_ERROR > > m_errors
 some can be PARSE_ERRORs also
 

Private Member Functions

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

Private Attributes

SYNC_QUEUE< wxString > m_queue
 
long long m_list_timestamp
 
PROGRESS_REPORTERm_progress_reporter
 
std::atomic_bool m_cancelled
 
std::mutex m_join
 
std::mutex m_loadInProgress
 

Detailed Description

Definition at line 84 of file footprint_info_impl.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_LIST_IMPL()

FOOTPRINT_LIST_IMPL::FOOTPRINT_LIST_IMPL ( )

Definition at line 294 of file footprint_info_impl.cpp.

References m_cancelled, m_list_timestamp, and m_progress_reporter.

◆ ~FOOTPRINT_LIST_IMPL()

virtual FOOTPRINT_LIST_IMPL::~FOOTPRINT_LIST_IMPL ( )
inlinevirtual

Definition at line 88 of file footprint_info_impl.h.

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 114 of file footprint_info_impl.cpp.

References FOOTPRINT_LIST::m_errors, and THROW_IO_ERROR.

Referenced by loadFootprints(), and ReadFootprintFiles().

◆ Clear()

void FOOTPRINT_LIST_IMPL::Clear ( )
overridevirtual
Returns
Clears the footprint info cache

Implements FOOTPRINT_LIST.

Definition at line 72 of file footprint_info_impl.cpp.

References FOOTPRINT_LIST::m_list, m_list_timestamp, and m_loadInProgress.

◆ DisplayErrors()

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

◆ GetAdapter()

FOOTPRINT_LIBRARY_ADAPTER * FOOTPRINT_LIST::GetAdapter ( ) const
inlineinherited

Definition at line 254 of file footprint_info.h.

References m_adapter.

◆ GetCount()

unsigned FOOTPRINT_LIST::GetCount ( ) const
inlineinherited
Returns
the number of items stored in list

Definition at line 175 of file footprint_info.h.

References m_list.

◆ GetErrorCount()

unsigned FOOTPRINT_LIST::GetErrorCount ( ) const
inlineinherited

Definition at line 213 of file footprint_info.h.

References m_errors.

◆ GetErrorMessages()

wxString FOOTPRINT_LIST::GetErrorMessages ( )
inherited

Returns all accumulated errors as a newline-separated string for display in the status bar.

This consumes the errors (pops them from the queue).

Definition at line 136 of file footprint_info.cpp.

References PopError().

Referenced by ReadFootprintFiles().

◆ GetFootprintInfo() [1/2]

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

Get info for a footprint by id.

Definition at line 53 of file footprint_info.cpp.

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

Referenced by Clear(), GetFootprintInfo(), and DISPLAY_FOOTPRINTS_FRAME::InitDisplay().

◆ 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 37 of file footprint_info.cpp.

References m_list.

◆ 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 208 of file footprint_info.h.

References m_list.

◆ GetList()

const std::vector< std::unique_ptr< FOOTPRINT_INFO > > & FOOTPRINT_LIST::GetList ( ) const
inlineinherited

Was forced to add this by modview_frame.cpp.

Definition at line 181 of file footprint_info.h.

References m_list.

Referenced by FOOTPRINT_LIST_IMPL::WithFootprintsForLibrary().

◆ loadFootprints()

◆ PopError()

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

Definition at line 218 of file footprint_info.h.

References m_errors.

Referenced by DisplayErrors(), and GetErrorMessages().

◆ PushError()

void FOOTPRINT_LIST::PushError ( std::unique_ptr< IO_ERROR > aError)
inlineinherited

Definition at line 226 of file footprint_info.h.

References m_errors.

◆ ReadFootprintFiles()

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

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

Parameters
aAdapteris used to access 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 145 of file footprint_info_impl.cpp.

References _, CatchErrors(), FOOTPRINT_LIBRARY_ADAPTER::GenerateTimestamp(), LIBRARY_MANAGER_ADAPTER::GetLibraryNames(), loadFootprints(), FOOTPRINT_LIST::m_adapter, m_cancelled, FOOTPRINT_LIST::m_errors, FOOTPRINT_LIST::m_list, m_list_timestamp, m_loadInProgress, m_progress_reporter, and m_queue.

◆ WithFootprintsForLibrary()

void FOOTPRINT_LIST_IMPL::WithFootprintsForLibrary ( const wxString & aLibName,
const std::function< void(const std::vector< LIB_TREE_ITEM * > &)> & aCallback )

Execute a callback with thread-safe access to the footprints for a library.

The callback receives a vector of pointers to footprint info objects. These pointers are only valid for the duration of the callback. The internal mutex is held while the callback executes, preventing modification of the underlying list.

Parameters
aLibNamethe library nickname to get footprints for
aCallbackfunction to call with the footprints vector

Definition at line 81 of file footprint_info_impl.cpp.

References dummy, FOOTPRINT_LIST::GetList(), and m_loadInProgress.

Member Data Documentation

◆ m_adapter

FOOTPRINT_LIBRARY_ADAPTER* FOOTPRINT_LIST::m_adapter
protectedinherited

◆ m_cancelled

std::atomic_bool FOOTPRINT_LIST_IMPL::m_cancelled
private

Definition at line 122 of file footprint_info_impl.h.

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

◆ m_errors

SYNC_QUEUE<std::unique_ptr<IO_ERROR> > FOOTPRINT_LIST::m_errors
protectedinherited

some can be PARSE_ERRORs also

Definition at line 260 of file footprint_info.h.

Referenced by FOOTPRINT_LIST_IMPL::CatchErrors(), GetErrorCount(), PopError(), PushError(), and FOOTPRINT_LIST_IMPL::ReadFootprintFiles().

◆ m_join

std::mutex FOOTPRINT_LIST_IMPL::m_join
private

Definition at line 123 of file footprint_info_impl.h.

◆ m_list

std::vector<std::unique_ptr<FOOTPRINT_INFO> > FOOTPRINT_LIST::m_list
protectedinherited

◆ m_list_timestamp

long long FOOTPRINT_LIST_IMPL::m_list_timestamp
private

Definition at line 120 of file footprint_info_impl.h.

Referenced by Clear(), FOOTPRINT_LIST_IMPL(), and ReadFootprintFiles().

◆ m_loadInProgress

std::mutex FOOTPRINT_LIST_IMPL::m_loadInProgress
private

Definition at line 124 of file footprint_info_impl.h.

Referenced by Clear(), ReadFootprintFiles(), and WithFootprintsForLibrary().

◆ m_progress_reporter

PROGRESS_REPORTER* FOOTPRINT_LIST_IMPL::m_progress_reporter
private

Definition at line 121 of file footprint_info_impl.h.

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

◆ m_queue

SYNC_QUEUE<wxString> FOOTPRINT_LIST_IMPL::m_queue
private

Definition at line 119 of file footprint_info_impl.h.

Referenced by loadFootprints(), and ReadFootprintFiles().


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