KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gpcb_plugin.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-2020 Wayne Stambaugh <[email protected]>
5 * Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.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
30#ifndef _GPCB_PLUGIN_H_
31#define _GPCB_PLUGIN_H_
32
33#include <io_mgr.h>
34#include <string>
35
36
37class GPCB_FPL_CACHE;
38
39
46class GPCB_PLUGIN : public PLUGIN
47{
48public:
49 const wxString PluginName() const override
50 {
51 return wxT( "gEDA PCB" );
52 }
53
55 {
56 return PLUGIN_FILE_DESC( _HKI( "gEDA PCB footprint file" ), { "fp" } );
57 }
58
60 {
61 return PLUGIN_FILE_DESC( _HKI( "gEDA PCB footprint library directory" ), {}, { "fp" },
62 false );
63 }
64
65 FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
66 const STRING_UTF8_MAP* aProperties ) override;
67
68 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
69 bool aBestEfforts,
70 const STRING_UTF8_MAP* aProperties = nullptr ) override;
71
72 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
73 const wxString& aFootprintName,
74 const STRING_UTF8_MAP* aProperties = nullptr ) override;
75
76 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
77 bool aKeepUUID = false,
78 const STRING_UTF8_MAP* aProperties = nullptr ) override;
79
80 void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
81 const STRING_UTF8_MAP* aProperties = nullptr ) override;
82
83 bool FootprintLibDelete( const wxString& aLibraryPath,
84 const STRING_UTF8_MAP* aProperties = nullptr ) override;
85
86 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
87
88 bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
89
90 //-----</PLUGIN API>--------------------------------------------------------
91
93
94 GPCB_PLUGIN( int aControlFlags );
95
97
98private:
99 void validateCache( const wxString& aLibraryPath, bool checkModified = true );
100
101 const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
102 const STRING_UTF8_MAP* aProperties, bool checkModified );
103
104 void init( const STRING_UTF8_MAP* aProperties );
105
106 friend class GPCB_FPL_CACHE;
107
108protected:
109 wxString m_error;
112 int m_ctl;
114 wxString m_filename;
115};
116
117#endif // _GPCB_PLUGIN_H_
A PLUGIN derivation for saving and loading Geda PCB files.
Definition: gpcb_plugin.h:47
bool FootprintLibDelete(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete an existing footprint library and returns true, or if library does not exist returns false,...
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
PLUGIN_FILE_DESC GetFootprintLibDesc() const override
Returns footprint library description for the PLUGIN.
Definition: gpcb_plugin.h:59
void init(const STRING_UTF8_MAP *aProperties)
wxString m_error
for throwing exceptions
Definition: gpcb_plugin.h:109
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
LINE_READER * m_reader
no ownership here.
Definition: gpcb_plugin.h:113
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:111
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
PLUGIN_FILE_DESC GetFootprintFileDesc() const override
Returns footprint file description for the PLUGIN.
Definition: gpcb_plugin.h:54
FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const STRING_UTF8_MAP *aProperties) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
wxString m_filename
for saves only, name is in m_reader for loads
Definition: gpcb_plugin.h:114
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
Definition: gpcb_plugin.h:49
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties, bool checkModified)
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
const STRING_UTF8_MAP * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: gpcb_plugin.h:110
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:270
A name/value tuple with unique names and optional values.
#define _HKI(x)
Container that describes file type info.