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-2016 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_TBL_MODEL;
34 
42 {
43  friend class FP_LIB_TABLE;
44 
45 public:
47 
48  FP_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
49  const wxString& aOptions, const wxString& aDescr = wxEmptyString ) :
50  LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
51  {
52  SetType( aType );
53  }
54 
56  type( IO_MGR::KICAD )
57  {
58  }
59 
60  bool operator==( const FP_LIB_TABLE_ROW& aRow ) const;
61 
62  bool operator!=( const FP_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); }
63 
69  const wxString GetType() const override { return IO_MGR::ShowType( type ); }
70 
76  void SetType( const wxString& aType ) override;
77 
78 protected:
80  LIB_TABLE_ROW( aRow ),
81  type( aRow.type )
82  {
83  }
84 
85 private:
86 
87  virtual LIB_TABLE_ROW* do_clone() const override
88  {
89  return new FP_LIB_TABLE_ROW( *this );
90  }
91 
92  void setPlugin( PLUGIN* aPlugin )
93  {
94  plugin.set( aPlugin );
95  }
96 
98  LIB_T type;
99 };
100 
101 
102 class FP_LIB_TABLE : public LIB_TABLE
103 {
104 public:
105 
106  virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
107 
108  virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
109 
120  FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable = NULL );
121 
131  const FP_LIB_TABLE_ROW* FindRow( const wxString& aNickName ) throw( IO_ERROR );
132 
133  //-----<PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
134 
146  wxArrayString FootprintEnumerate( const wxString& aNickname );
147 
159  void PrefetchLib( const wxString& aNickname );
160 
175  MODULE* FootprintLoad( const wxString& aNickname, const wxString& aFootprintName );
176 
181  enum SAVE_T
182  {
185  };
186 
205  SAVE_T FootprintSave( const wxString& aNickname, const MODULE* aFootprint,
206  bool aOverwrite = true );
207 
219  void FootprintDelete( const wxString& aNickname, const wxString& aFootprintName );
220 
229  bool IsFootprintLibWritable( const wxString& aNickname );
230 
231  void FootprintLibDelete( const wxString& aNickname );
232 
233  void FootprintLibCreate( const wxString& aNickname );
234 
235  //-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
236 
249  MODULE* FootprintLoadWithOptionalNickname( const LIB_ID& aFootprintId )
250  throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception );
251 
265  static bool LoadGlobalTable( FP_LIB_TABLE& aTable )
266  throw (IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception );
267 
273  static wxString GetGlobalTableFileName();
274 
284  static const wxString GlobalPathEnvVariableName();
285 };
286 
287 
288 extern FP_LIB_TABLE GFootprintTable; // KIFACE scope.
289 
290 #endif // FP_LIB_TABLE_H_
void setPlugin(PLUGIN *aPlugin)
Definition: fp_lib_table.h:92
bool IsFootprintLibWritable(const wxString &aNickname)
Function IsFootprintLibWritable.
Class LIB_TABLE_ROW.
Class FP_LIB_TABLE_ROW.
Definition: fp_lib_table.h:41
bool operator!=(const FP_LIB_TABLE_ROW &aRow) const
Definition: fp_lib_table.h:62
Class FP_TBL_MODEL mixes in FP_LIB_TABLE into wxGridTableBase so the result can be used as a table wi...
wxArrayString FootprintEnumerate(const wxString &aNickname)
Function FootprintEnumerate returns a list of footprint names contained within the library given by a...
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:87
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:321
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:46
PLUGIN::RELEASER plugin
Definition: fp_lib_table.h:97
Class RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destruct...
Definition: io_mgr.h:476
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:504
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
Function Format.
FP_LIB_TABLE_ROW(const FP_LIB_TABLE_ROW &aRow)
Definition: fp_lib_table.h:79
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:48
SAVE_T
Enum SAVE_T is the set of return values from FootprintSave() below.
Definition: fp_lib_table.h:181
Struct PARSE_ERROR contains a filename or source description, a problem input line, a line number, a byte offset, and an error message which contains the the caller's report and his call site information: CPP source file, function, and line number.
Definition: ki_exception.h:94
Class PLUGIN is a base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:193
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.
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
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
const wxString GetType() const override
Function GetType.
Definition: fp_lib_table.h:69
static wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.
Class LIB_TABLE.