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
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() const 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
86 std::vector<SEARCH_TERM>& GetSearchTerms() override;
87
88 unsigned GetNumberedPadCount() const
89 {
90 if( !m_loaded )
91 return 0;
92
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
137 void cacheSearchTerms();
138
140
142
143 wxString m_nickname;
144 wxString m_fpname;
145 int m_num;
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};
Helper class to handle the list of footprints available in libraries.
wxString m_doc
Footprint description.
int GetPinCount() const override
The pin count for symbols or the unique pad count for footprints.
virtual ~FOOTPRINT_INFO()=default
int m_num
Order number in the display list.
LIB_ID GetLIB_ID() const override
wxString GetName() const override
wxString m_fpname
Module name.
wxString GetLibNickname() const override
const wxString & GetFootprintName() const
unsigned GetNumberedPadCount()
virtual void load()
lazily load stuff not filled in by constructor. This may throw IO_ERRORS.
unsigned GetNumberedPadCount() const
wxString m_keywords
Footprint keywords.
unsigned m_numbered_pad_count
Number of unique electrical pads (numeric or BGA-style numbers)
wxString GetKeywords()
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...
A list of FOOTPRINT_INFO objects, along with a list of IO_ERROR objects or PARSE_ERRORs that were thr...
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
Clear the footprint info cache.
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:348
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 FOOTPRINT_INFO &lhs, const FOOTPRINT_INFO &rhs)
#define APIEXPORT
Macros which export functions from a DLL/DSO.