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 (C) 2012-2024 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
50
51 bool operator==( const DESIGN_BLOCK_LIB_TABLE_ROW& aRow ) const;
52
53 bool operator!=( const DESIGN_BLOCK_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); }
54
58 const wxString GetType() const override { return DESIGN_BLOCK_IO_MGR::ShowType( type ); }
59
63 void SetType( const wxString& aType ) override;
64
66
67protected:
69 LIB_TABLE_ROW( aRow ), type( aRow.type )
70 {
71 }
72
73private:
74 virtual LIB_TABLE_ROW* do_clone() const override
75 {
76 return new DESIGN_BLOCK_LIB_TABLE_ROW( *this );
77 }
78
79 void setPlugin( DESIGN_BLOCK_IO* aPlugin ) { plugin.reset( aPlugin ); }
80
82
83private:
86};
87
88
90{
91public:
93
94 virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
95
96 virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
97
106 DESIGN_BLOCK_LIB_TABLE( DESIGN_BLOCK_LIB_TABLE* aFallBackTable = nullptr );
107
108 bool operator==( const DESIGN_BLOCK_LIB_TABLE& aFpTable ) const;
109
110 bool operator!=( const DESIGN_BLOCK_LIB_TABLE& r ) const { return !( *this == r ); }
111
127 const DESIGN_BLOCK_LIB_TABLE_ROW* FindRow( const wxString& aNickName,
128 bool aCheckIfEnabled = false );
129
139 void DesignBlockEnumerate( wxArrayString& aDesignBlockNames, const wxString& aNickname,
140 bool aBestEfforts );
141
146 long long GenerateTimestamp( const wxString* aNickname );
147
158 void PrefetchLib( const wxString& aNickname );
159
173 DESIGN_BLOCK* DesignBlockLoad( const wxString& aNickname, const wxString& aDesignBlockName,
174 bool aKeepUUID = false );
175
179 bool DesignBlockExists( const wxString& aNickname, const wxString& aDesignBlockName );
180
187 const DESIGN_BLOCK* GetEnumeratedDesignBlock( const wxString& aNickname,
188 const wxString& aDesignBlockName );
193 {
196 };
197
212 SAVE_T DesignBlockSave( const wxString& aNickname, const DESIGN_BLOCK* aDesignBlock,
213 bool aOverwrite = true );
214
223 void DesignBlockDelete( const wxString& aNickname, const wxString& aDesignBlockName );
224
232 bool IsDesignBlockLibWritable( const wxString& aNickname );
233
234 void DesignBlockLibDelete( const wxString& aNickname );
235
236 void DesignBlockLibCreate( const wxString& aNickname );
237
252 DESIGN_BLOCK* DesignBlockLoadWithOptionalNickname( const LIB_ID& aDesignBlockId,
253 bool aKeepUUID = false );
254
267 static bool LoadGlobalTable( DESIGN_BLOCK_LIB_TABLE& aTable );
268
269 static DESIGN_BLOCK_LIB_TABLE& GetGlobalLibTable();
270
271 static DESIGN_BLOCK_LIST_IMPL& GetGlobalList();
272
276 static wxString GetGlobalTableFileName();
277
286 static const wxString GlobalPathEnvVariableName();
287
288private:
290};
291
292#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)
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 ...
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