KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_info.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2011 Jean-Pierre Charras, <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#pragma once
26
27#include <boost/ptr_container/ptr_vector.hpp>
28#include <import_export.h>
29#include <ki_exception.h>
30#include <core/sync_queue.h>
31#include <lib_tree_item.h>
32#include <atomic>
33#include <functional>
34#include <memory>
35
36
38class FOOTPRINT_LIST;
41class wxTopLevelWindow;
42class KIWAY;
43class wxTextFile;
44
45
46/*
47 * Helper class to handle the list of footprints available in libraries. It stores
48 * footprint names, doc and keywords.
49 *
50 * This is a virtual class; its implementation lives in pcbnew/footprint_info_impl.cpp.
51 * To get instances of these classes, see FOOTPRINT_LIST::GetInstance().
52 */
54{
55public:
56 virtual ~FOOTPRINT_INFO() = default;
57
58 // These two accessors do not have to call ensure_loaded(), because constructor
59 // fills in these fields:
60
61 const wxString& GetFootprintName() const { return m_fpname; }
62
63 wxString GetLibNickname() const override { return m_nickname; }
64
65 wxString GetName() const override { return m_fpname; }
66
67 int GetPinCount() override { return GetNumberedPadCount(); }
68
69 LIB_ID GetLIB_ID() const override
70 {
71 return LIB_ID( m_nickname, m_fpname );
72 }
73
74 wxString GetDesc() override
75 {
77 return m_doc;
78 }
79
80 wxString GetKeywords()
81 {
83 return m_keywords;
84 }
85
86 std::vector<SEARCH_TERM>& GetSearchTerms() override;
87
88 unsigned GetPadCount()
89 {
91 return m_pad_count;
92 }
93
95 {
97 return m_unique_pad_count;
98 }
99
101 {
104 }
105
107 {
109 return m_num;
110 }
111
120 bool InLibrary( const wxString& aLibrary ) const;
121
125 friend bool operator<( const FOOTPRINT_INFO& lhs, const FOOTPRINT_INFO& rhs );
126
127protected:
129 {
130 if( !m_loaded )
131 load();
132 }
133
135 virtual void load() { };
136
138
140
141 wxString m_nickname;
142 wxString m_fpname;
143 int m_num;
144 unsigned m_pad_count;
147 wxString m_doc;
148 wxString m_keywords;
149
150 std::vector<SEARCH_TERM> m_searchTerms;
151};
152
153
162{
163public:
165 m_adapter( nullptr )
166 {
167 }
168
169 virtual ~FOOTPRINT_LIST() = default;
170
171 unsigned GetCount() const { return m_list.size(); }
172
173 const std::vector<std::unique_ptr<FOOTPRINT_INFO>>& GetList() const { return m_list; }
174
178 virtual void Clear() = 0;
179
183 FOOTPRINT_INFO* GetFootprintInfo( const wxString& aFootprintName );
184
188 FOOTPRINT_INFO* GetFootprintInfo( const wxString& aLibNickname, const wxString& aFootprintName );
189
196 FOOTPRINT_INFO& GetItem( unsigned aIdx ) const
197 {
198 return *m_list[aIdx];
199 }
200
201 unsigned GetErrorCount() const
202 {
203 return m_errors.size();
204 }
205
206 std::unique_ptr<IO_ERROR> PopError()
207 {
208 std::unique_ptr<IO_ERROR> error;
209
210 m_errors.pop( error );
211 return error;
212 }
213
214 void PushError( std::unique_ptr<IO_ERROR> aError )
215 {
216 m_errors.move_push( std::move( aError ) );
217 }
218
231 virtual bool ReadFootprintFiles( FOOTPRINT_LIBRARY_ADAPTER* aAdapter, const wxString* aNickname = nullptr,
232 PROGRESS_REPORTER* aProgressReporter = nullptr ) = 0;
233
238 wxString GetErrorMessages();
239
241
242protected:
244
245 std::vector<std::unique_ptr<FOOTPRINT_INFO>> m_list;
247};
248
wxString m_doc
Footprint description.
virtual ~FOOTPRINT_INFO()=default
int m_num
Order number in the display list.
int GetPinCount() override
The pin count for symbols or the unique pad count for footprints.
LIB_ID GetLIB_ID() const override
wxString GetName() const override
wxString m_fpname
Module name.
wxString GetLibNickname() const override
const wxString & GetFootprintName() const
unsigned GetPadCount()
unsigned GetNumberedPadCount()
virtual void load()
lazily load stuff not filled in by constructor. This may throw IO_ERRORS.
wxString m_keywords
Footprint keywords.
unsigned GetUniquePadCount()
unsigned m_numbered_pad_count
Number of unique electrical pads (numeric or BGA-style numbers)
unsigned m_unique_pad_count
Number of unique pads.
wxString GetKeywords()
unsigned m_pad_count
Number of pads.
FOOTPRINT_LIST * m_owner
provides access to FP_LIB_TABLE
wxString m_nickname
library as known in FP_LIB_TABLE
wxString GetDesc() override
std::vector< SEARCH_TERM > m_searchTerms
An interface to the global shared library manager that is schematic-specific and linked to one projec...
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
virtual bool ReadFootprintFiles(FOOTPRINT_LIBRARY_ADAPTER *aAdapter, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)=0
Read all the footprints provided by the combination of aTable and aNickname.
unsigned GetErrorCount() const
wxString GetErrorMessages()
Returns all accumulated errors as a newline-separated string for display in the status bar.
FOOTPRINT_INFO * GetFootprintInfo(const wxString &aFootprintName)
Get info for a footprint by id.
virtual ~FOOTPRINT_LIST()=default
SYNC_QUEUE< std::unique_ptr< IO_ERROR > > m_errors
some can be PARSE_ERRORs also
unsigned GetCount() const
FOOTPRINT_INFO & GetItem(unsigned aIdx) const
Get info for a footprint by index.
std::vector< std::unique_ptr< FOOTPRINT_INFO > > m_list
virtual void Clear()=0
FOOTPRINT_LIBRARY_ADAPTER * m_adapter
no ownership
std::unique_ptr< IO_ERROR > PopError()
const std::vector< std::unique_ptr< FOOTPRINT_INFO > > & GetList() const
FOOTPRINT_LIBRARY_ADAPTER * GetAdapter() const
void PushError(std::unique_ptr< IO_ERROR > aError)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:315
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:49
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
virtual std::vector< SEARCH_TERM > & GetSearchTerms()=0
A progress reporter interface for use in multi-threaded environments.
Synchronized, locking queue.
Definition sync_queue.h:32
bool operator<(const DESIGN_BLOCK_INFO &lhs, const DESIGN_BLOCK_INFO &rhs)
#define APIEXPORT
Macros which export functions from a DLL/DSO.