KiCad PCB EDA Suite
fp_lib_table.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) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef FP_LIB_TABLE_H_
27#define FP_LIB_TABLE_H_
28
29#include <lib_table_base.h>
30#include <io_mgr.h>
31
32class FOOTPRINT;
34
35
41{
42public:
44
45 FP_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
46 const wxString& aOptions, const wxString& aDescr = wxEmptyString ) :
47 LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
48 {
49 SetType( aType );
50 }
51
53 type( IO_MGR::KICAD_SEXP )
54 {
55 }
56
57 bool operator==( const FP_LIB_TABLE_ROW& aRow ) const;
58
59 bool operator!=( const FP_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); }
60
64 const wxString GetType() const override { return IO_MGR::ShowType( type ); }
65
69 void SetType( const wxString& aType ) override;
70
71protected:
73 LIB_TABLE_ROW( aRow ),
74 type( aRow.type )
75 {
76 }
77
78private:
79 virtual LIB_TABLE_ROW* do_clone() const override
80 {
81 return new FP_LIB_TABLE_ROW( *this );
82 }
83
84 void setPlugin( PLUGIN* aPlugin )
85 {
86 plugin.set( aPlugin );
87 }
88
89 friend class FP_LIB_TABLE;
90
93};
94
95
96class FP_LIB_TABLE : public LIB_TABLE
97{
98public:
99 KICAD_T Type() override { return FP_LIB_TABLE_T; }
100
101 virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
102
103 virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
104
113 FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable = nullptr );
114
115 bool operator==( const FP_LIB_TABLE& aFpTable ) const;
116
117 bool operator!=( const FP_LIB_TABLE& r ) const { return !( *this == r ); }
118
134 const FP_LIB_TABLE_ROW* FindRow( const wxString& aNickName, bool aCheckIfEnabled = false );
135
145 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname,
146 bool aBestEfforts );
147
152 long long GenerateTimestamp( const wxString* aNickname );
153
164 void PrefetchLib( const wxString& aNickname );
165
179 FOOTPRINT* FootprintLoad( const wxString& aNickname, const wxString& aFootprintName,
180 bool aKeepUUID = false );
181
185 bool FootprintExists( const wxString& aNickname, const wxString& aFootprintName );
186
193 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aNickname,
194 const wxString& aFootprintName );
199 {
202 };
203
218 SAVE_T FootprintSave( const wxString& aNickname, const FOOTPRINT* aFootprint,
219 bool aOverwrite = true );
220
229 void FootprintDelete( const wxString& aNickname, const wxString& aFootprintName );
230
238 bool IsFootprintLibWritable( const wxString& aNickname );
239
240 void FootprintLibDelete( const wxString& aNickname );
241
242 void FootprintLibCreate( const wxString& aNickname );
243
259 bool aKeepUUID = false );
260
273 static bool LoadGlobalTable( FP_LIB_TABLE& aTable );
274
278 static wxString GetGlobalTableFileName();
279
288 static const wxString GlobalPathEnvVariableName();
289
290private:
291 friend class FP_LIB_TABLE_GRID;
292};
293
294
295extern FP_LIB_TABLE GFootprintTable; // KIFACE scope.
296
297#endif // FP_LIB_TABLE_H_
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:41
virtual LIB_TABLE_ROW * do_clone() const override
Definition: fp_lib_table.h:79
bool operator!=(const FP_LIB_TABLE_ROW &aRow) const
Definition: fp_lib_table.h:59
IO_MGR::PCB_FILE_T LIB_T
Definition: fp_lib_table.h:43
void SetType(const wxString &aType) override
Change the type represented by this row.
FP_LIB_TABLE_ROW(const wxString &aNick, const wxString &aURI, const wxString &aType, const wxString &aOptions, const wxString &aDescr=wxEmptyString)
Definition: fp_lib_table.h:45
const wxString GetType() const override
return the type of footprint library table represented by this row.
Definition: fp_lib_table.h:64
FP_LIB_TABLE_ROW(const FP_LIB_TABLE_ROW &aRow)
Definition: fp_lib_table.h:72
bool operator==(const FP_LIB_TABLE_ROW &aRow) const
void setPlugin(PLUGIN *aPlugin)
Definition: fp_lib_table.h:84
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:91
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
void FootprintDelete(const wxString &aNickname, const wxString &aFootprintName)
Delete the aFootprintName from the library given by aNickname.
bool operator!=(const FP_LIB_TABLE &r) const
Definition: fp_lib_table.h:117
static bool LoadGlobalTable(FP_LIB_TABLE &aTable)
Load the global footprint library table into aTable.
bool operator==(const FP_LIB_TABLE &aFpTable) const
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname, bool aBestEfforts)
Return a list of footprint names contained within the library given by aNickname.
void FootprintLibCreate(const wxString &aNickname)
KICAD_T Type() override
Definition: fp_lib_table.h:99
FP_LIB_TABLE(FP_LIB_TABLE *aFallBackTable=nullptr)
Build a footprint library table by pre-pending this table fragment in front of aFallBackTable.
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aNickname, const wxString &aFootprintName)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
static const wxString GlobalPathEnvVariableName()
Return the name of the environment variable used to hold the directory of locally installed "KiCad sp...
FOOTPRINT * FootprintLoadWithOptionalNickname(const LIB_ID &aFootprintId, bool aKeepUUID=false)
Load a footprint having aFootprintId with possibly an empty nickname.
long long GenerateTimestamp(const wxString *aNickname)
Generate a hashed timestamp representing the last-mod-times of the library indicated by aNickname,...
void FootprintLibDelete(const wxString &aNickname)
bool FootprintExists(const wxString &aNickname, const wxString &aFootprintName)
Indicates whether or not the given footprint already exists in the given library.
virtual void Parse(LIB_TABLE_LEXER *aLexer) override
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
void PrefetchLib(const wxString &aNickname)
If possible, prefetches the specified library (e.g.
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
SAVE_T
The set of return values from FootprintSave() below.
Definition: fp_lib_table.h:199
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
SAVE_T FootprintSave(const wxString &aNickname, const FOOTPRINT *aFootprint, bool aOverwrite=true)
Write aFootprint to an existing library given by aNickname.
static wxString GetGlobalTableFileName()
A factory which returns an instance of a PLUGIN.
Definition: io_mgr.h:46
static const wxString ShowType(PCB_FILE_T aFileType)
Return a brief name for a plugin given aFileType enum.
Definition: io_mgr.cpp:77
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
Definition: io_mgr.h:54
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:310
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:564
void set(PLUGIN *aPlugin)
Definition: io_mgr.h:591
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:270
E_SERIE r
Definition: eserie.cpp:41
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ FP_LIB_TABLE_T
Definition: typeinfo.h:236