KiCad PCB EDA Suite
symbol_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) 2016-2017 Wayne Stambaugh <stambaughw@verizon.net>
5  * Copyright (C) 2016-2017 KiCad Developers, see change_log.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, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef _SYMBOL_LIB_TABLE_H_
26 #define _SYMBOL_LIB_TABLE_H_
27 
28 #include <lib_table_base.h>
29 #include <sch_io_mgr.h>
30 
31 class LIB_PART;
32 
40 {
41  friend class SYMBOL_LIB_TABLE;
42 
43 public:
45 
46  SYMBOL_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
47  const wxString& aOptions = wxEmptyString,
48  const wxString& aDescr = wxEmptyString ) :
49  LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
50  {
51  SetType( aType );
52  }
53 
55  type( SCH_IO_MGR::SCH_KICAD )
56  {
57  }
58 
59  bool operator==( const SYMBOL_LIB_TABLE_ROW& aRow ) const;
60 
61  bool operator!=( const SYMBOL_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); }
62 
68  const wxString GetType() const override { return SCH_IO_MGR::ShowType( type ); }
69 
75  void SetType( const wxString& aType ) override;
76 
77 protected:
79  LIB_TABLE_ROW( aRow ),
80  type( aRow.type )
81  {
82  }
83 
84 private:
85 
86  virtual LIB_TABLE_ROW* do_clone() const override
87  {
88  return new SYMBOL_LIB_TABLE_ROW( *this );
89  }
90 
91  void setPlugin( SCH_PLUGIN* aPlugin )
92  {
93  plugin.set( aPlugin );
94  }
95 
97  LIB_T type;
98 };
99 
100 
102 {
103 public:
104 
105  virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
106 
107  virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
108 
119  SYMBOL_LIB_TABLE( SYMBOL_LIB_TABLE* aFallBackTable = NULL );
120 
130  const SYMBOL_LIB_TABLE_ROW* FindRow( const wxString& aNickName );
131 
132  //-----<PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
133 
144  void EnumerateSymbolLib( const wxString& aNickname, wxArrayString& aAliasNames );
145 
161  LIB_ALIAS* LoadSymbol( const wxString& aNickname, const wxString& aAliasName );
162 
168  enum SAVE_T
169  {
172  };
173 
195  SAVE_T SaveSymbol( const wxString& aNickname, const LIB_PART* aSymbol,
196  bool aOverwrite = true );
197 
209  void DeleteSymbol( const wxString& aNickname, const wxString& aSymbolName );
210 
227  void DeleteAlias( const wxString& aNickname, const wxString& aAliasName );
228 
237  bool IsSymbolLibWritable( const wxString& aNickname );
238 
239  void DeleteSymbolLib( const wxString& aNickname );
240 
241  void CreateSymbolLib( const wxString& aNickname );
242 
243  //-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
244 
258 
272  static bool LoadGlobalTable( SYMBOL_LIB_TABLE& aTable );
273 
279  static wxString GetGlobalTableFileName();
280 
290  static const wxString GlobalPathEnvVariableName();
291 
293 
294  static const wxString& GetSymbolLibTableFileName();
295 };
296 
297 
298 #endif // _SYMBOL_LIB_TABLE_H_
bool operator!=(const SYMBOL_LIB_TABLE_ROW &aRow) const
Class SCH_IO_MGR is a factory which returns an instance of a SCH_PLUGIN.
Definition: sch_io_mgr.h:44
void EnumerateSymbolLib(const wxString &aNickname, wxArrayString &aAliasNames)
Function EnumerateSymbolLib.
LIB_ALIAS * LoadSymbol(const wxString &aNickname, const wxString &aAliasName)
Function LoadSymbol.
SAVE_T SaveSymbol(const wxString &aNickname, const LIB_PART *aSymbol, bool aOverwrite=true)
Function SaveSymbol.
static const wxString & GetSymbolLibTableFileName()
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
Part library alias object definition.
Class SYMBOL_LIB_TABLE_ROW.
Class LIB_TABLE_ROW.
SYMBOL_LIB_TABLE(SYMBOL_LIB_TABLE *aFallBackTable=NULL)
Constructor SYMBOL_LIB_TABLE.
SYMBOL_LIB_TABLE_ROW(const SYMBOL_LIB_TABLE_ROW &aRow)
const SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName)
Function FindRow.
void CreateSymbolLib(const wxString &aNickname)
SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin
void DeleteSymbolLib(const wxString &aNickname)
void SetType(const wxString &aType) override
Function SetType.
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
Definition: sch_io_mgr.cpp:75
static const wxString GlobalPathEnvVariableName()
Function GlobalPathEnvVarVariableName.
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:529
Class LIB_ID.
Definition: lib_id.h:56
bool IsSymbolLibWritable(const wxString &aNickname)
Function IsSymbolLibWritable.
bool operator==(const SYMBOL_LIB_TABLE_ROW &aRow) const
LIB_ALIAS * LoadSymbolWithOptionalNickname(const LIB_ID &aId)
Function LoadSymboldWithOptionalNickname loads a LIB_PART having aFootprintId with possibly an empty ...
Base class that schematic file and library loading and saving plugins should derive from...
Definition: sch_io_mgr.h:184
static bool LoadGlobalTable(SYMBOL_LIB_TABLE &aTable)
Function LoadGlobalTable.
const wxString GetType() const override
Function GetType.
Class LIB_PART defines a library part object.
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indention level of aIndentLevel.
void setPlugin(SCH_PLUGIN *aPlugin)
SCH_IO_MGR::SCH_FILE_T LIB_T
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:501
virtual LIB_TABLE_ROW * do_clone() const override
void DeleteSymbol(const wxString &aNickname, const wxString &aSymbolName)
Function DeleteSymbol.
virtual void Parse(LIB_TABLE_LEXER *aLexer) override
Function Parse.
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.
SAVE_T
Enum SAVE_T.
static wxString GetGlobalTableFileName()
Function GetGlobalTableFileName.
void DeleteAlias(const wxString &aNickname, const wxString &aAliasName)
Function DeleteAlias.
SCH_FILE_T
A set of file types that the SCH_IO_MGR knows about, and for which there has been a plugin written...
Definition: sch_io_mgr.h:52
SYMBOL_LIB_TABLE_ROW(const wxString &aNick, const wxString &aURI, const wxString &aType, const wxString &aOptions=wxEmptyString, const wxString &aDescr=wxEmptyString)
Class LIB_TABLE.