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=NULL)=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 std::unique_ptr< FOOTPRINT_LISTGetInstance (KIWAY &aKiway)
 Factory function to return a new 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 size_t CountFinished ()=0
 Return the number of libraries finished (successfully or otherwise). 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 169 of file footprint_info.h.

Member Typedef Documentation

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

Definition at line 177 of file footprint_info.h.

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

Definition at line 176 of file footprint_info.h.

Constructor & Destructor Documentation

FOOTPRINT_LIST::FOOTPRINT_LIST ( )
inline

Definition at line 186 of file footprint_info.h.

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

Definition at line 190 of file footprint_info.h.

191  {
192  }

Member Function Documentation

void FOOTPRINT_LIST::AddItem ( FOOTPRINT_INFO aItem)

Add aItem to list.

Parameters
aItem= item to add
virtual size_t FOOTPRINT_LIST::CountFinished ( )
protectedpure virtual

Return the number of libraries finished (successfully or otherwise).

Implemented in FOOTPRINT_LIST_IMPL.

Referenced by FOOTPRINT_ASYNC_LOADER::GetProgress().

void FOOTPRINT_LIST::DisplayErrors ( wxTopLevelWindow *  aCaller = NULL)

Definition at line 83 of file footprint_info.cpp.

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

Referenced by PCB_BASE_FRAME::SelectFootprint().

84 {
85  // @todo: go to a more HTML !<table>! ? centric output, possibly with
86  // recommendations for remedy of errors. Add numeric error codes
87  // to PARSE_ERROR, and switch on them for remedies, etc. Full
88  // access is provided to everything in every exception!
89 
90  HTML_MESSAGE_BOX dlg( aWindow, _( "Load Error" ) );
91 
92  dlg.MessageSet( _( "Errors were encountered loading footprints:" ) );
93 
94  wxString msg;
95 
96  while( auto error = PopError() )
97  {
98  msg += wxT( "<p>" ) + error->Problem() + wxT( "</p>" );
99  }
100 
101  dlg.AddHTML_Text( msg );
102 
103  dlg.ShowModal();
104 }
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 197 of file footprint_info.h.

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

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

Definition at line 231 of file footprint_info.h.

References SYNC_QUEUE< T >::size().

Referenced by PCB_BASE_FRAME::SelectFootprint().

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

Factory function to return a new 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 132 of file footprint_info.cpp.

References get_instance_from_id(), and KIFACE_NEW_FOOTPRINT_LIST.

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

133 {
135 }
Return a new instance of FOOTPRINT_LIST from pcbnew.
Definition: kiface_ids.h:39
static std::unique_ptr< FOOTPRINT_LIST > get_instance_from_id(KIWAY &aKiway, int aId)
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 220 of file footprint_info.h.

Referenced by PCB_BASE_FRAME::SelectFootprint().

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

Was forced to add this by modview_frame.cpp.

Definition at line 203 of file footprint_info.h.

References FOOTPRINT_ASYNC_LOADER::m_list.

204  {
205  return m_list;
206  }
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 53 of file footprint_info.cpp.

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

Referenced by DisplayCmpDoc().

54 {
55  if( aFootprintName.IsEmpty() )
56  return NULL;
57 
58  for( auto& fp : m_list )
59  {
60  LIB_ID fpid;
61 
62  wxCHECK_MSG( fpid.Parse( TO_UTF8( aFootprintName ) ) < 0, NULL,
64  "'%s' is not a valid LIB_ID.", aFootprintName ) );
65 
66  wxString libNickname = FROM_UTF8( fpid.GetLibNickname() );
67  wxString footprintName = FROM_UTF8( fpid.GetLibItemName() );
68 
69  if( libNickname == fp->GetNickname() && footprintName == fp->GetFootprintName() )
70  return &*fp;
71  }
72 
73  return NULL;
74 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
int Parse(const UTF8 &aId)
Function Parse.
Definition: lib_id.cpp:122
Class LIB_ID.
Definition: lib_id.h:56
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
const UTF8 & GetLibItemName() const
Function GetLibItemName.
Definition: lib_id.h:129
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
Function GetLibNickname.
Definition: lib_id.h:108
FP_LIB_TABLE* FOOTPRINT_LIST::GetTable ( ) const
inline

Definition at line 258 of file footprint_info.h.

Referenced by FOOTPRINT_INFO_IMPL::load().

259  {
260  return m_lib_table;
261  }
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 236 of file footprint_info.h.

References SYNC_QUEUE< T >::pop().

Referenced by DisplayErrors().

237  {
238  std::unique_ptr<IO_ERROR> error;
239 
240  m_errors.pop( error );
241  return error;
242  }
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 = NULL 
)
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.
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.

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().

Friends And Related Function Documentation

friend class FOOTPRINT_ASYNC_LOADER
friend

Definition at line 171 of file footprint_info.h.

Member Data Documentation

ERRLIST FOOTPRINT_LIST::m_errors
protected

some can be PARSE_ERRORs also

Definition at line 180 of file footprint_info.h.

Referenced by FOOTPRINT_LIST_IMPL::CatchErrors(), FOOTPRINT_LIST_IMPL::JoinWorkers(), and FOOTPRINT_LIST_IMPL::StartWorkers().

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


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