KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <pcb_io/pcb_io_mgr.h>
31
32class FOOTPRINT;
34class PCB_IO;
35
36
42{
43public:
44 FP_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
45 const wxString& aOptions, const wxString& aDescr = wxEmptyString ) :
46 LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
47 {
48 SetType( aType );
49 }
50
52 type( PCB_IO_MGR::KICAD_SEXP )
53 {
54 }
55
56 bool operator==( const FP_LIB_TABLE_ROW& aRow ) const;
57
58 bool operator!=( const FP_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); }
59
63 const wxString GetType() const override { return PCB_IO_MGR::ShowType( type ); }
64
68 void SetType( const wxString& aType ) override;
69
71
72protected:
74 LIB_TABLE_ROW( aRow ),
75 type( aRow.type )
76 {
77 }
78
79private:
80 virtual LIB_TABLE_ROW* do_clone() const override
81 {
82 return new FP_LIB_TABLE_ROW( *this );
83 }
84
85 void setPlugin( PCB_IO* aPlugin )
86 {
87 plugin.reset( aPlugin );
88 }
89
90 friend class FP_LIB_TABLE;
91
92private:
95};
96
97
98class FP_LIB_TABLE : public LIB_TABLE
99{
100public:
102
103 virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
104
105 virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
106
115 FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable = nullptr );
116
117 bool operator==( const FP_LIB_TABLE& aFpTable ) const;
118
119 bool operator!=( const FP_LIB_TABLE& r ) const { return !( *this == r ); }
120
136 const FP_LIB_TABLE_ROW* FindRow( const wxString& aNickName, bool aCheckIfEnabled = false );
137
147 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname,
148 bool aBestEfforts );
149
154 long long GenerateTimestamp( const wxString* aNickname );
155
166 void PrefetchLib( const wxString& aNickname );
167
181 FOOTPRINT* FootprintLoad( const wxString& aNickname, const wxString& aFootprintName,
182 bool aKeepUUID = false );
183
187 bool FootprintExists( const wxString& aNickname, const wxString& aFootprintName );
188
195 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aNickname,
196 const wxString& aFootprintName );
201 {
204 };
205
220 SAVE_T FootprintSave( const wxString& aNickname, const FOOTPRINT* aFootprint,
221 bool aOverwrite = true );
222
231 void FootprintDelete( const wxString& aNickname, const wxString& aFootprintName );
232
240 bool IsFootprintLibWritable( const wxString& aNickname );
241
242 void FootprintLibDelete( const wxString& aNickname );
243
244 void FootprintLibCreate( const wxString& aNickname );
245
261 bool aKeepUUID = false );
262
275 static bool LoadGlobalTable( FP_LIB_TABLE& aTable );
276
280 static wxString GetGlobalTableFileName();
281
290 static const wxString GlobalPathEnvVariableName();
291
292private:
293 friend class FP_LIB_TABLE_GRID;
294};
295
296
297extern FP_LIB_TABLE GFootprintTable; // KIFACE scope.
298
299#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 t...
Definition: fp_lib_table.h:42
void setPlugin(PCB_IO *aPlugin)
Definition: fp_lib_table.h:85
virtual LIB_TABLE_ROW * do_clone() const override
Definition: fp_lib_table.h:80
bool operator!=(const FP_LIB_TABLE_ROW &aRow) const
Definition: fp_lib_table.h:58
void SetType(const wxString &aType) override
Change the type represented by this row.
IO_RELEASER< PCB_IO > plugin
Definition: fp_lib_table.h:93
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:44
const wxString GetType() const override
return the type of footprint library table represented by this row.
Definition: fp_lib_table.h:63
FP_LIB_TABLE_ROW(const FP_LIB_TABLE_ROW &aRow)
Definition: fp_lib_table.h:73
bool operator==(const FP_LIB_TABLE_ROW &aRow) const
PCB_IO_MGR::PCB_FILE_T GetFileType()
Definition: fp_lib_table.h:70
PCB_IO_MGR::PCB_FILE_T type
Definition: fp_lib_table.h:94
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:119
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)
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:201
PROJECT::ELEM ProjectElementType() override
Definition: fp_lib_table.h:101
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 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:322
A factory which returns an instance of a #PLUGIN.
Definition: pcb_io_mgr.h:48
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
Definition: pcb_io_mgr.h:56
static const wxString ShowType(PCB_FILE_T aFileType)
Return a brief name for a plugin given aFileType enum.
Definition: pcb_io_mgr.cpp:78
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:71
ELEM
The set of #_ELEMs that a PROJECT can hold.
Definition: project.h:70
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:150
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition: io_mgr.h:33