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 Types

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

Public Member Functions

 FOOTPRINT_LIST ()
 
virtual ~FOOTPRINT_LIST ()
 
virtual void WriteCacheToFile (const wxString &aFilePath)
 
virtual void ReadCacheFromFile (const wxString &aFilePath)
 
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 ()
 
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 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...
 

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

Member Typedef Documentation

◆ ERRLIST

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

Definition at line 170 of file footprint_info.h.

◆ FPILIST

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

Definition at line 169 of file footprint_info.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_LIST()

FOOTPRINT_LIST::FOOTPRINT_LIST ( )
inline

Definition at line 172 of file footprint_info.h.

172  : m_lib_table( 0 )
173  {
174  }
FP_LIB_TABLE * m_lib_table
no ownership

◆ ~FOOTPRINT_LIST()

virtual FOOTPRINT_LIST::~FOOTPRINT_LIST ( )
inlinevirtual

Definition at line 176 of file footprint_info.h.

177  {
178  }

Member Function Documentation

◆ Clear()

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

Definition at line 200 of file footprint_info.h.

201  {
202  m_list.clear();
203  }

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ DisplayErrors()

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

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( "\n", "<BR>" );
111  msg += wxT( "<p>" ) + tmp + wxT( "</p>" );
112  }
113 
114  dlg.AddHTML_Text( msg );
115 
116  dlg.ShowModal();
117 }
HTML_MESSAGE_BOX.
std::unique_ptr< IO_ERROR > PopError()
#define _(s)
Definition: 3d_actions.cpp:33

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

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

◆ GetCount()

unsigned FOOTPRINT_LIST::GetCount ( ) const
inline

◆ GetErrorCount()

unsigned FOOTPRINT_LIST::GetErrorCount ( ) const
inline

Definition at line 227 of file footprint_info.h.

228  {
229  return m_errors.size();
230  }
ERRLIST m_errors
some can be PARSE_ERRORs also
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)

Get info for a footprint by id.

Definition at line 58 of file footprint_info.cpp.

59 {
60  if( aFootprintName.IsEmpty() )
61  return NULL;
62 
63  LIB_ID fpid;
64 
65  wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
66  wxString::Format( wxT( "\"%s\" is not a valid LIB_ID." ), aFootprintName ) );
67 
68  return GetFootprintInfo( fpid.GetLibNickname(), fpid.GetLibItemName() );
69 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
#define NULL
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
FOOTPRINT_INFO * GetFootprintInfo(const wxString &aFootprintName)
Get info for a footprint by id.
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
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122

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

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

◆ GetFootprintInfo() [2/2]

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

Get info for a footprint by libNickname/footprintName.

Definition at line 42 of file footprint_info.cpp.

44 {
45  if( aFootprintName.IsEmpty() )
46  return NULL;
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 NULL;
55 }
#define NULL

References m_list, and NULL.

◆ GetInstance()

FOOTPRINT_LIST * FOOTPRINT_LIST::GetInstance ( KIWAY aKiway)
static

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

140 {
141  FOOTPRINT_LIST* footprintInfo = get_instance_from_id( aKiway, KIFACE_FOOTPRINT_LIST );
142 
143  if( ! footprintInfo )
144  return nullptr;
145 
146  if( !footprintInfo->GetCount() )
147  {
148  footprintInfo->ReadCacheFromFile( aKiway.Prj().GetProjectPath() + "fp-info-cache" );
149  }
150 
151  return footprintInfo;
152 }
static FOOTPRINT_LIST * get_instance_from_id(KIWAY &aKiway, int aId)
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:173
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
unsigned GetCount() const
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)
Return a pointer to the global instance of FOOTPRINT_LIST from pcbnew.
Definition: kiface_ids.h:39

References get_instance_from_id(), GetCount(), PROJECT::GetProjectPath(), KIFACE_FOOTPRINT_LIST, KIWAY::Prj(), and 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
inline

Get info for a footprint by index.

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

Definition at line 222 of file footprint_info.h.

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

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

◆ GetList()

const FPILIST& FOOTPRINT_LIST::GetList ( ) const
inline

Was forced to add this by modview_frame.cpp.

Definition at line 192 of file footprint_info.h.

193  {
194  return m_list;
195  }

Referenced by FP_TREE_MODEL_ADAPTER::getFootprints().

◆ GetTable()

FP_LIB_TABLE* FOOTPRINT_LIST::GetTable ( ) const
inline

Definition at line 257 of file footprint_info.h.

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

Referenced by FOOTPRINT_INFO_IMPL::load().

◆ joinWorkers()

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

◆ PopError()

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

Definition at line 232 of file footprint_info.h.

233  {
234  std::unique_ptr<IO_ERROR> error;
235 
236  m_errors.pop( error );
237  return error;
238  }
bool pop(T &aReceiver)
Pop a value if the queue into the provided variable.
Definition: sync_queue.h:63
ERRLIST m_errors
some can be PARSE_ERRORs also

Referenced by DisplayErrors().

◆ ReadCacheFromFile()

virtual void FOOTPRINT_LIST::ReadCacheFromFile ( const wxString &  aFilePath)
inlinevirtual

Reimplemented in FOOTPRINT_LIST_IMPL.

Definition at line 181 of file footprint_info.h.

181 {};

Referenced by GetInstance().

◆ ReadFootprintFiles()

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
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 CVPCB_MAINFRAME::LoadFootprintFiles().

◆ startWorkers()

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

◆ stopWorkers()

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

◆ WriteCacheToFile()

virtual void FOOTPRINT_LIST::WriteCacheToFile ( const wxString &  aFilePath)
inlinevirtual

Reimplemented in FOOTPRINT_LIST_IMPL.

Definition at line 180 of file footprint_info.h.

180 {};

Friends And Related Function Documentation

◆ FOOTPRINT_ASYNC_LOADER

friend class FOOTPRINT_ASYNC_LOADER
friend

Definition at line 290 of file footprint_info.h.

Member Data Documentation

◆ m_errors

ERRLIST FOOTPRINT_LIST::m_errors
protected

◆ m_lib_table

FP_LIB_TABLE* FOOTPRINT_LIST::m_lib_table
protected

◆ m_list


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