KiCad PCB EDA Suite
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-2017 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 
37 class GPCB_FPL_CACHE;
38 
39 
46 class GPCB_PLUGIN : public PLUGIN
47 {
48 public:
49  const wxString PluginName() const override
50  {
51  return wxT( "Geda PCB" );
52  }
53 
54  const wxString GetFileExtension() const override
55  {
56  return wxT( "fp" );
57  }
58 
59  void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
60  bool aBestEfforts,
61  const PROPERTIES* aProperties = nullptr ) override;
62 
63  const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
64  const wxString& aFootprintName,
65  const PROPERTIES* aProperties = nullptr ) override;
66 
67  FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
68  bool aKeepUUID = false,
69  const PROPERTIES* aProperties = nullptr ) override;
70 
71  void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
72  const PROPERTIES* aProperties = nullptr ) override;
73 
74  bool FootprintLibDelete( const wxString& aLibraryPath,
75  const PROPERTIES* aProperties = nullptr ) override;
76 
77  long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
78 
79  bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
80 
81  //-----</PLUGIN API>--------------------------------------------------------
82 
83  GPCB_PLUGIN();
84 
85  GPCB_PLUGIN( int aControlFlags );
86 
87  ~GPCB_PLUGIN();
88 
89 private:
90  void validateCache( const wxString& aLibraryPath, bool checkModified = true );
91 
92  const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
93  const PROPERTIES* aProperties, bool checkModified );
94 
95  void init( const PROPERTIES* aProperties );
96 
97  friend class GPCB_FPL_CACHE;
98 
99 protected:
100  wxString m_error;
103  int m_ctl;
105  wxString m_filename;
106 };
107 
108 #endif // _GPCB_PLUGIN_H_
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
A PLUGIN derivation for saving and loading Geda PCB files.
Definition: gpcb_plugin.h:46
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const PROPERTIES *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
A name/value tuple with unique names and optional values.
Definition: properties.h:33
void init(const PROPERTIES *aProperties)
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const PROPERTIES *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:102
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
Definition: gpcb_plugin.h:49
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: gpcb_plugin.h:101
bool FootprintLibDelete(const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr) override
Delete an existing footprint library and returns true, or if library does not exist returns false,...
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
const wxString GetFileExtension() const override
Returns the file extension for the PLUGIN.
Definition: gpcb_plugin.h:54
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:269
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
LINE_READER * m_reader
no ownership here.
Definition: gpcb_plugin.h:104
wxString m_error
for throwing exceptions
Definition: gpcb_plugin.h:100
wxString m_filename
for saves only, name is in m_reader for loads
Definition: gpcb_plugin.h:105
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.