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 <dick@softplc.com>
5  * Copyright (C) 2012-2017 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2012-2017 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 
32 class MODULE;
33 class FP_LIB_TABLE_GRID;
34 
35 
43 {
44  friend class FP_LIB_TABLE;
45 
46 public:
48 
49  FP_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
50  const wxString& aOptions, const wxString& aDescr = wxEmptyString ) :
51  LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
52  {
53  SetType( aType );
54  }
55 
57  type( IO_MGR::KICAD )
58  {
59  }
60 
61  bool operator==( const FP_LIB_TABLE_ROW& aRow ) const;
62 
63  bool operator!=( const FP_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); }
64 
70  const wxString GetType() const override { return IO_MGR::ShowType( type ); }
71 
77  void SetType( const wxString& aType ) override;
78 
79 protected:
81  LIB_TABLE_ROW( aRow ),
82  type( aRow.type )
83  {
84  }
85 
86 private:
87 
88  virtual LIB_TABLE_ROW* do_clone() const override
89  {
90  return new FP_LIB_TABLE_ROW( *this );
91  }
92 
93  void setPlugin( PLUGIN* aPlugin )
94  {
95  plugin.set( aPlugin );
96  }
97 
99  LIB_T type;
100 };
101 
102 
103 class FP_LIB_TABLE : public LIB_TABLE
104 {
105  friend class FP_LIB_TABLE_GRID;
106 
107 public:
108 
109  virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
110 
111  virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
112 
123  FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable = NULL );
124 
125 
126  bool operator==( const FP_LIB_TABLE& aFpTable ) const;
127 
128  bool operator!=( const FP_LIB_TABLE& r ) const { return !( *this == r ); }
129 
139  const FP_LIB_TABLE_ROW* FindRow( const wxString& aNickName );
140 
141  //-----<PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
142 
152  void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname );
153 
165  void PrefetchLib( const wxString& aNickname );
166 
181  MODULE* FootprintLoad( const wxString& aNickname, const wxString& aFootprintName );
182 
187  enum SAVE_T
188  {
191  };
192 
211  SAVE_T FootprintSave( const wxString& aNickname, const MODULE* aFootprint,
212  bool aOverwrite = true );
213 
225  void FootprintDelete( const wxString& aNickname, const wxString& aFootprintName );
226 
235  bool IsFootprintLibWritable( const wxString& aNickname );
236 
237  void FootprintLibDelete( const wxString& aNickname );
238 
239  void FootprintLibCreate( const wxString& aNickname );
240 
241  //-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
242 
255  MODULE* FootprintLoadWithOptionalNickname( const LIB_ID& aFootprintId );
256 
270  static bool LoadGlobalTable( FP_LIB_TABLE& aTable );
271 
277  static wxString GetGlobalTableFileName();
278 
288  static const wxString GlobalPathEnvVariableName();
289 };
290 
291 
292 extern FP_LIB_TABLE GFootprintTable; // KIFACE scope.
293 
294 #endif // FP_LIB_TABLE_H_
void setPlugin(PLUGIN *aPlugin)
Definition: fp_lib_table.h:93
bool operator!=(const FP_LIB_TABLE &r) const
Definition: fp_lib_table.h:128
bool IsFootprintLibWritable(const wxString &aNickname)
Function IsFootprintLibWritable.
Class LIB_TABLE_ROW.
Class FP_LIB_TABLE_ROW.
Definition: fp_lib_table.h:42
bool operator!=(const FP_LIB_TABLE_ROW &aRow) const
Definition: fp_lib_table.h:63
MODULE * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName)
Function FootprintLoad.
FP_LIB_TABLE(FP_LIB_TABLE *aFallBackTable=NULL)
Constructor FP_LIB_TABLE.
virtual LIB_TABLE_ROW * do_clone() const override
Definition: fp_lib_table.h:88
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
bool operator==(const FP_LIB_TABLE &aFpTable) const
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:311
static const wxString ShowType(PCB_FILE_T aFileType)
Function ShowType returns a brief name for a plugin, given aFileType enum.
Definition: io_mgr.cpp:105
Class LIB_ID.
Definition: lib_id.h:56
void FootprintLibDelete(const wxString &aNickname)
IO_MGR::PCB_FILE_T LIB_T
Definition: fp_lib_table.h:47
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:98
Class RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destruct...
Definition: io_mgr.h:474
Class IO_MGR is a factory which returns an instance of a PLUGIN.
Definition: io_mgr.h:42
static const wxString GlobalPathEnvVariableName()
Function GlobalPathEnvVarVariableName.
virtual void Parse(LIB_TABLE_LEXER *aLexer) override
Function Parse.
static bool LoadGlobalTable(FP_LIB_TABLE &aTable)
Function LoadGlobalTable loads the global footprint library table into aTable.
void set(PLUGIN *aPlugin)
Definition: io_mgr.h:502
void PrefetchLib(const wxString &aNickname)
Function PrefetchLib If possible, prefetches the specified library (e.g.
bool operator==(const FP_LIB_TABLE_ROW &aRow) const
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indention level of aIndentLevel.
FP_LIB_TABLE_ROW(const FP_LIB_TABLE_ROW &aRow)
Definition: fp_lib_table.h:80
void FootprintLibCreate(const wxString &aNickname)
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName)
Function FindRow.
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:49
SAVE_T
Enum SAVE_T is the set of return values from FootprintSave() below.
Definition: fp_lib_table.h:187
Class PLUGIN is a base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:193
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
Class LIB_TABLE_LEXER is an automatically generated class using the TokenList2DnsLexer.cmake technology, based on keywords provided by file: /home/kicad/workspace/kicad-doxygen/common/lib_table.keywords.
MODULE * FootprintLoadWithOptionalNickname(const LIB_ID &aFootprintId)
Function FootprintLoadWithOptionalNickname loads a footprint having aFootprintId with possibly an emp...
void SetType(const wxString &aType) override
Function SetType.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname)
Return a list of footprint names contained within the library given by aNickname. ...
SAVE_T FootprintSave(const wxString &aNickname, const MODULE *aFootprint, bool aOverwrite=true)
Function FootprintSave.
void FootprintDelete(const wxString &aNickname, const wxString &aFootprintName)
Function FootprintDelete.
PCB_FILE_T
Enum PCB_FILE_T is a set of file types that the IO_MGR knows about, and for which there has been a pl...
Definition: io_mgr.h:51
const wxString GetType() const override
Function GetType.
Definition: fp_lib_table.h:70
static wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.
Class LIB_TABLE.