KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block_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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef DESIGN_BLOCK_LIB_TABLE_H_
25#define DESIGN_BLOCK_LIB_TABLE_H_
26
27#include <kicommon.h>
28#include <lib_table_base.h>
29#include <design_block_io.h>
31
32class DESIGN_BLOCK;
34
40{
41public:
42 DESIGN_BLOCK_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
43 const wxString& aOptions, const wxString& aDescr = wxEmptyString ) :
44 LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
45 {
46 SetType( aType );
47 }
48
51 type( DESIGN_BLOCK_IO_MGR::KICAD_SEXP )
52 {
53 }
54
55 bool operator==( const DESIGN_BLOCK_LIB_TABLE_ROW& aRow ) const;
56
57 bool operator!=( const DESIGN_BLOCK_LIB_TABLE_ROW& aRow ) const
58 {
59 return !( *this == aRow );
60 }
61
65 const wxString GetType() const override { return DESIGN_BLOCK_IO_MGR::ShowType( type ); }
66
70 void SetType( const wxString& aType ) override;
71
72 bool LibraryExists() const override
73 {
74 if( plugin )
75 return plugin->CanReadLibrary( GetFullURI( true ) );
76
77 return false;
78 }
79
81
82protected:
84 LIB_TABLE_ROW( aRow ),
85 type( aRow.type )
86 {
87 }
88
89private:
90 virtual LIB_TABLE_ROW* do_clone() const override
91 {
92 return new DESIGN_BLOCK_LIB_TABLE_ROW( *this );
93 }
94
95 void setPlugin( DESIGN_BLOCK_IO* aPlugin ) { plugin.reset( aPlugin ); }
96
98
99private:
102};
103
104
106{
107public:
109
110 virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
111
112 virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
113
122 DESIGN_BLOCK_LIB_TABLE( DESIGN_BLOCK_LIB_TABLE* aFallBackTable = nullptr );
123
124 bool operator==( const DESIGN_BLOCK_LIB_TABLE& aFpTable ) const;
125
126 bool operator!=( const DESIGN_BLOCK_LIB_TABLE& r ) const { return !( *this == r ); }
127
143 const DESIGN_BLOCK_LIB_TABLE_ROW* FindRow( const wxString& aNickName,
144 bool aCheckIfEnabled = false );
145
156 void DesignBlockEnumerate( wxArrayString& aDesignBlockNames, const wxString& aNickname,
157 bool aBestEfforts );
158
163 long long GenerateTimestamp( const wxString* aNickname );
164
178 DESIGN_BLOCK* DesignBlockLoad( const wxString& aNickname, const wxString& aDesignBlockName,
179 bool aKeepUUID = false );
180
184 bool DesignBlockExists( const wxString& aNickname, const wxString& aDesignBlockName );
185
192 const DESIGN_BLOCK* GetEnumeratedDesignBlock( const wxString& aNickname,
193 const wxString& aDesignBlockName );
198 {
201 };
202
217 SAVE_T DesignBlockSave( const wxString& aNickname, const DESIGN_BLOCK* aDesignBlock,
218 bool aOverwrite = true );
219
229 void DesignBlockDelete( const wxString& aNickname, const wxString& aDesignBlockName );
230
238 bool IsDesignBlockLibWritable( const wxString& aNickname );
239
240 void DesignBlockLibDelete( const wxString& aNickname );
241
242 void DesignBlockLibCreate( const wxString& aNickname );
243
258 DESIGN_BLOCK* DesignBlockLoadWithOptionalNickname( const LIB_ID& aDesignBlockId,
259 bool aKeepUUID = false );
260
273 static bool LoadGlobalTable( DESIGN_BLOCK_LIB_TABLE& aTable );
274
275 static DESIGN_BLOCK_LIB_TABLE& GetGlobalLibTable();
276
277 static DESIGN_BLOCK_LIST_IMPL& GetGlobalList();
278
282 static wxString GetGlobalTableFileName();
283
292 static const wxString GlobalPathEnvVariableName();
293
294private:
296};
297
298#endif // DESIGN_BLOCK_LIB_TABLE_H_
static const wxString ShowType(DESIGN_BLOCK_FILE_T aFileType)
This class builds a wxGridTableBase by wrapping an DESIGN_BLOCK_LIB_TABLE object.
Hold a record identifying a library accessed by the appropriate design block library #PLUGIN object i...
DESIGN_BLOCK_LIB_TABLE_ROW(const DESIGN_BLOCK_LIB_TABLE_ROW &aRow)
const wxString GetType() const override
Return the type of design block library table represented by this row.
DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T GetFileType()
DESIGN_BLOCK_LIB_TABLE_ROW(const wxString &aNick, const wxString &aURI, const wxString &aType, const wxString &aOptions, const wxString &aDescr=wxEmptyString)
bool LibraryExists() const override
void setPlugin(DESIGN_BLOCK_IO *aPlugin)
DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T type
virtual LIB_TABLE_ROW * do_clone() const override
IO_RELEASER< DESIGN_BLOCK_IO > plugin
bool operator!=(const DESIGN_BLOCK_LIB_TABLE_ROW &aRow) const
bool operator!=(const DESIGN_BLOCK_LIB_TABLE &r) const
PROJECT::ELEM ProjectElementType() override
SAVE_T
The set of return values from DesignBlockSave() below.
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.
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Serialize this object as utf8 text to an OUTPUTFORMATTER, and tries to make it look good using multip...
virtual void SetType(const wxString &aType)=0
Change the type of library represented by this row that must be implemented in the derived object to ...
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
bool operator==(const LIB_TABLE_ROW &r) const
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
ELEM
The set of #_ELEMs that a PROJECT can hold.
Definition: project.h:70
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition: io_mgr.h:33
#define KICOMMON_API
Definition: kicommon.h:28