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, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <boost/ptr_container/ptr_vector.hpp>
24#include <import_export.h>
25#include <ki_exception.h>
26#include <core/sync_queue.h>
27#include <lib_tree_item.h>
28#include <atomic>
29#include <functional>
30#include <memory>
31
32
34class FOOTPRINT_LIST;
37class wxTopLevelWindow;
38class KIWAY;
39class wxTextFile;
40
41
42/*
43 * Helper class to handle the list of footprints available in libraries. It stores
44 * footprint names, doc and keywords.
45 *
46 * This is a virtual class; its implementation lives in pcbnew/footprint_info_impl.cpp.
47 * To get instances of these classes, see FOOTPRINT_LIST::GetInstance().
48 */
50{
51public:
52 virtual ~FOOTPRINT_INFO() = default;
53
54 // These two accessors do not have to call ensure_loaded(), because constructor
55 // fills in these fields:
56
57 const wxString& GetFootprintName() const { return m_fpname; }
58
59 wxString GetLibNickname() const override { return m_nickname; }
60
61 wxString GetName() const override { return m_fpname; }
62
63 int GetPinCount() override { return GetNumberedPadCount(); }
64
65 LIB_ID GetLIB_ID() const override
66 {
67 return LIB_ID( m_nickname, m_fpname );
68 }
69
70 wxString GetDesc() override
71 {
73 return m_doc;
74 }
75
76 wxString GetKeywords()
77 {
79 return m_keywords;
80 }
81
82 std::vector<SEARCH_TERM>& GetSearchTerms() override;
83
84 unsigned GetPadCount()
85 {
87 return m_pad_count;
88 }
89
91 {
93 return m_unique_pad_count;
94 }
95
97 {
100 }
101
103 {
105 return m_num;
106 }
107
116 bool InLibrary( const wxString& aLibrary ) const;
117
121 friend bool operator<( const FOOTPRINT_INFO& lhs, const FOOTPRINT_INFO& rhs );
122
123protected:
125 {
126 if( !m_loaded )
127 load();
128 }
129
131 virtual void load() { };
132
134
136
137 wxString m_nickname;
138 wxString m_fpname;
139 int m_num;
140 unsigned m_pad_count;
143 wxString m_doc;
144 wxString m_keywords;
145
146 std::vector<SEARCH_TERM> m_searchTerms;
147};
148
149
158{
159public:
161 m_adapter( nullptr )
162 {
163 }
164
165 virtual ~FOOTPRINT_LIST() = default;
166
167 unsigned GetCount() const { return m_list.size(); }
168
169 const std::vector<std::unique_ptr<FOOTPRINT_INFO>>& GetList() const { return m_list; }
170
174 virtual void Clear() = 0;
175
179 FOOTPRINT_INFO* GetFootprintInfo( const wxString& aFootprintName );
180
184 FOOTPRINT_INFO* GetFootprintInfo( const wxString& aLibNickname, const wxString& aFootprintName );
185
192 FOOTPRINT_INFO& GetItem( unsigned aIdx ) const
193 {
194 return *m_list[aIdx];
195 }
196
197 unsigned GetErrorCount() const
198 {
199 return m_errors.size();
200 }
201
202 std::unique_ptr<IO_ERROR> PopError()
203 {
204 std::unique_ptr<IO_ERROR> error;
205
206 m_errors.pop( error );
207 return error;
208 }
209
210 void PushError( std::unique_ptr<IO_ERROR> aError )
211 {
212 m_errors.move_push( std::move( aError ) );
213 }
214
227 virtual bool ReadFootprintFiles( FOOTPRINT_LIBRARY_ADAPTER* aAdapter, const wxString* aNickname = nullptr,
228 PROGRESS_REPORTER* aProgressReporter = nullptr ) = 0;
229
234 wxString GetErrorMessages();
235
237
238protected:
240
241 std::vector<std::unique_ptr<FOOTPRINT_INFO>> m_list;
243};
244
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:311
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
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.