KiCad PCB EDA Suite
FOOTPRINT_LIST Class Referenceabstract

Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thrown acquiring the FOOTPRINT_INFOs. More...

#include <footprint_info.h>

Inheritance diagram for FOOTPRINT_LIST:
FOOTPRINT_LIST_IMPL

Public Member Functions

 FOOTPRINT_LIST ()
 
virtual ~FOOTPRINT_LIST ()
 
unsigned GetCount () const
 
const FPILISTGetList () const
 Was forced to add this by modview_frame.cpp. More...
 
FOOTPRINT_INFOGetModuleInfo (const wxString &aFootprintName)
 Get info for a module by name. More...
 
FOOTPRINT_INFOGetItem (unsigned aIdx)
 Get info for a module by index. More...
 
void AddItem (FOOTPRINT_INFO *aItem)
 Add aItem to list. More...
 
unsigned GetErrorCount () const
 
std::unique_ptr< IO_ERRORPopError ()
 
virtual bool ReadFootprintFiles (FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)=0
 Read all the footprints provided by the combination of aTable and aNickname. More...
 
void DisplayErrors (wxTopLevelWindow *aCaller=NULL)
 
FP_LIB_TABLEGetTable () const
 

Static Public Member Functions

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

Protected Types

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

Protected Member Functions

virtual void StartWorkers (FP_LIB_TABLE *aTable, wxString const *aNickname, FOOTPRINT_ASYNC_LOADER *aLoader, unsigned aNThreads)=0
 Launch worker threads to load footprints. More...
 
virtual bool JoinWorkers ()=0
 Join worker threads. More...
 
virtual void StopWorkers ()=0
 Stop worker threads. More...
 

Protected Attributes

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

Friends

class FOOTPRINT_ASYNC_LOADER
 

Detailed Description

Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thrown acquiring the FOOTPRINT_INFOs.

This is a virtual class; its implementation lives in pcbnew/footprint_info_impl.cpp. To get instances of these classes, see FOOTPRINT_LIST::GetInstance().

Definition at line 170 of file footprint_info.h.

Member Typedef Documentation

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

Definition at line 178 of file footprint_info.h.

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

Definition at line 177 of file footprint_info.h.

Constructor & Destructor Documentation

FOOTPRINT_LIST::FOOTPRINT_LIST ( )
inline

Definition at line 187 of file footprint_info.h.

187  : m_lib_table( 0 )
188  {
189  }
FP_LIB_TABLE * m_lib_table
no ownership
virtual FOOTPRINT_LIST::~FOOTPRINT_LIST ( )
inlinevirtual

Definition at line 191 of file footprint_info.h.

192  {
193  }

Member Function Documentation

void FOOTPRINT_LIST::AddItem ( FOOTPRINT_INFO aItem)

Add aItem to list.

Parameters
aItem= item to add
void FOOTPRINT_LIST::DisplayErrors ( wxTopLevelWindow *  aCaller = NULL)

Definition at line 84 of file footprint_info.cpp.

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

Referenced by CVPCB_MAINFRAME::LoadFootprintFiles(), PCB_BASE_FRAME::LoadModuleFromLibrary(), and PCB_BASE_FRAME::SelectFootprint().

85 {
86  // @todo: go to a more HTML !<table>! ? centric output, possibly with
87  // recommendations for remedy of errors. Add numeric error codes
88  // to PARSE_ERROR, and switch on them for remedies, etc. Full
89  // access is provided to everything in every exception!
90 
91  HTML_MESSAGE_BOX dlg( aWindow, _( "Load Error" ) );
92 
93  dlg.MessageSet( _( "Errors were encountered loading footprints:" ) );
94 
95  wxString msg;
96 
97  while( auto error = PopError() )
98  {
99  wxString tmp = error->Problem();
100 
101  // Preserve new lines in error messages so queued errors don't run together.
102  tmp.Replace( "\n", "<BR>" );
103  msg += wxT( "<p>" ) + tmp + wxT( "</p>" );
104  }
105 
106  dlg.AddHTML_Text( msg );
107 
108  dlg.ShowModal();
109 }
Class HTML_MESSAGE_BOX.
std::unique_ptr< IO_ERROR > PopError()
unsigned FOOTPRINT_LIST::GetCount ( ) const
inline
Returns
the number of items stored in list

Definition at line 198 of file footprint_info.h.

Referenced by FOOTPRINT_FILTER::ITERATOR::dereference(), FOOTPRINT_FILTER::end(), FOOTPRINT_FILTER::ITERATOR::increment(), and PCB_BASE_FRAME::SelectFootprint().

199  {
200  return m_list.size();
201  }
unsigned FOOTPRINT_LIST::GetErrorCount ( ) const
inline

Definition at line 232 of file footprint_info.h.

References SYNC_QUEUE< T >::size().

Referenced by CVPCB_MAINFRAME::LoadFootprintFiles(), PCB_BASE_FRAME::LoadModuleFromLibrary(), and PCB_BASE_FRAME::SelectFootprint().

233  {
234  return m_errors.size();
235  }
size_t size() const
Return the size of the queue.
Definition: sync_queue.h:94
ERRLIST m_errors
some can be PARSE_ERRORs also
FOOTPRINT_LIST * FOOTPRINT_LIST::GetInstance ( KIWAY aKiway)
static

Factory function to return a FOOTPRINT_LIST via Kiway.

NOT guaranteed to succeed; will return null if the kiface is not available.

Parameters
aKiway- active kiway instance

Definition at line 137 of file footprint_info.cpp.

References get_instance_from_id(), and KIFACE_FOOTPRINT_LIST.

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

138 {
140 }
static FOOTPRINT_LIST * get_instance_from_id(KIWAY &aKiway, int aId)
Return a pointer to the global instance of FOOTPRINT_LIST from pcbnew.
Definition: kiface_ids.h:39
FOOTPRINT_INFO& FOOTPRINT_LIST::GetItem ( unsigned  aIdx)
inline

Get info for a module by index.

Parameters
aIdx= index of the given item
Returns
the aIdx item in list

Definition at line 221 of file footprint_info.h.

Referenced by FOOTPRINT_FILTER::ITERATOR::dereference(), and PCB_BASE_FRAME::SelectFootprint().

222  {
223  return *m_list[aIdx];
224  }
const FPILIST& FOOTPRINT_LIST::GetList ( ) const
inline

Was forced to add this by modview_frame.cpp.

Definition at line 204 of file footprint_info.h.

References FOOTPRINT_ASYNC_LOADER::m_list.

205  {
206  return m_list;
207  }
FOOTPRINT_INFO * FOOTPRINT_LIST::GetModuleInfo ( const wxString &  aFootprintName)

Get info for a module by name.

Parameters
aFootprintName= the footprint name inside the FOOTPRINT_INFO of interest.
Returns
FOOTPRINT_INF* - the item stored in list if found

Definition at line 54 of file footprint_info.cpp.

References Format(), GetChars(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), m_list, and LIB_ID::Parse().

Referenced by CVPCB_MAINFRAME::AutomaticFootprintMatching(), DisplayCmpDoc(), CVPCB_MAINFRAME::DisplayStatus(), and DISPLAY_FOOTPRINTS_FRAME::InitDisplay().

55 {
56  if( aFootprintName.IsEmpty() )
57  return NULL;
58 
59  for( auto& fp : m_list )
60  {
61  LIB_ID fpid;
62 
63  wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
65  wxT( "\"%s\" is not a valid LIB_ID." ), GetChars( aFootprintName ) ) );
66 
67  wxString libNickname = fpid.GetLibNickname();
68  wxString footprintName = fpid.GetLibItemName();
69 
70  if( libNickname == fp->GetNickname() && footprintName == fp->GetFootprintName() )
71  return &*fp;
72  }
73 
74  return NULL;
75 }
int Parse(const UTF8 &aId)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
const UTF8 & GetLibItemName() const
Definition: lib_id.h:118
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:101
FP_LIB_TABLE* FOOTPRINT_LIST::GetTable ( ) const
inline

Definition at line 262 of file footprint_info.h.

Referenced by FOOTPRINT_INFO_IMPL::load().

263  {
264  return m_lib_table;
265  }
FP_LIB_TABLE * m_lib_table
no ownership
virtual bool FOOTPRINT_LIST::JoinWorkers ( )
protectedpure virtual

Join worker threads.

Part of the FOOTPRINT_ASYNC_LOADER implementation.

Implemented in FOOTPRINT_LIST_IMPL.

Referenced by FOOTPRINT_ASYNC_LOADER::Join().

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

Definition at line 237 of file footprint_info.h.

References SYNC_QUEUE< T >::pop().

Referenced by DisplayErrors().

238  {
239  std::unique_ptr<IO_ERROR> error;
240 
241  m_errors.pop( error );
242  return error;
243  }
bool pop(T &aReceiver)
Pop a value off the queue into the provided variable.
Definition: sync_queue.h:66
ERRLIST m_errors
some can be PARSE_ERRORs also
virtual bool FOOTPRINT_LIST::ReadFootprintFiles ( FP_LIB_TABLE aTable,
const wxString *  aNickname = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
pure virtual

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
bool - 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.

Implemented in FOOTPRINT_LIST_IMPL.

Referenced by FOOTPRINT_SELECT_WIDGET::Load(), CVPCB_MAINFRAME::LoadFootprintFiles(), and CVPCB_MAINFRAME::OnEditFootprintLibraryTable().

virtual void FOOTPRINT_LIST::StartWorkers ( FP_LIB_TABLE aTable,
wxString const *  aNickname,
FOOTPRINT_ASYNC_LOADER aLoader,
unsigned  aNThreads 
)
protectedpure virtual

Launch worker threads to load footprints.

Part of the FOOTPRINT_ASYNC_LOADER implementation.

Implemented in FOOTPRINT_LIST_IMPL.

Referenced by FOOTPRINT_ASYNC_LOADER::Start().

virtual void FOOTPRINT_LIST::StopWorkers ( )
protectedpure virtual

Stop worker threads.

Part of the FOOTPRINT_ASYNC_LOADER implementation.

Implemented in FOOTPRINT_LIST_IMPL.

Referenced by FOOTPRINT_ASYNC_LOADER::Abort().

Friends And Related Function Documentation

friend class FOOTPRINT_ASYNC_LOADER
friend

Definition at line 172 of file footprint_info.h.

Member Data Documentation

ERRLIST FOOTPRINT_LIST::m_errors
protected
FP_LIB_TABLE* FOOTPRINT_LIST::m_lib_table
protected
FPILIST FOOTPRINT_LIST::m_list
protected
MUTEX FOOTPRINT_LIST::m_list_lock
protected

Definition at line 183 of file footprint_info.h.


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