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-2017 Wayne Stambaugh <stambaughw@verizon.net>
5  * Copyright (C) 1992-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 
47 class GPCB_PLUGIN : public PLUGIN
48 {
49  friend class GPCB_FPL_CACHE;
50 
51 public:
52 
53  //-----<PLUGIN API>---------------------------------------------------------
54 
55  const wxString PluginName() const override
56  {
57  return wxT( "Geda PCB" );
58  }
59 
60  const wxString GetFileExtension() const override
61  {
62  return wxT( "fp" );
63  }
64 
65  void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
66  const PROPERTIES* aProperties = NULL) override;
67 
68  const MODULE* GetEnumeratedFootprint( const wxString& aLibraryPath,
69  const wxString& aFootprintName,
70  const PROPERTIES* aProperties = NULL ) override;
71 
72  MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
73  const PROPERTIES* aProperties = NULL ) override;
74 
75  void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
76  const PROPERTIES* aProperties = NULL ) override;
77 
78  bool FootprintLibDelete( const wxString& aLibraryPath,
79  const PROPERTIES* aProperties = NULL ) override;
80 
81  long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
82 
83  bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
84 
85  //-----</PLUGIN API>--------------------------------------------------------
86 
87  GPCB_PLUGIN();
88 
89  GPCB_PLUGIN( int aControlFlags );
90 
91  ~GPCB_PLUGIN();
92 
93 protected:
94 
95  wxString m_error;
98  int m_ctl;
100  wxString m_filename;
101 
102 private:
103  void validateCache( const wxString& aLibraryPath, bool checkModified = true );
104 
105  const MODULE* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
106  const PROPERTIES* aProperties, bool checkModified );
107 
108  void init( const PROPERTIES* aProperties );
109 };
110 
111 #endif // _GPCB_PLUGIN_H_
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
Class GPCB_PLUGIN is a PLUGIN derivation for saving and loading Geda PCB files.
Definition: gpcb_plugin.h:47
MODULE * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
Function FootprintLoad loads a footprint having aFootprintName from the aLibraryPath containing a lib...
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Function IsFootprintLibWritable returns true iff the library at aLibraryPath is writable.
const MODULE * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
Function GetEnumeratedFootprint a version of FootprintLoad() for use after FootprintEnumerate() for m...
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
void init(const PROPERTIES *aProperties)
GPCB_FPL_CACHE * m_cache
Footprint library cache.
Definition: gpcb_plugin.h:97
const MODULE * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties, bool checkModified)
const wxString PluginName() const override
Function PluginName returns a brief hard coded name for this PLUGIN.
Definition: gpcb_plugin.h:55
const PROPERTIES * m_props
passed via Save() or Load(), no ownership, may be NULL.
Definition: gpcb_plugin.h:96
const wxString GetFileExtension() const override
Function GetFileExtension returns the file extension for the PLUGIN.
Definition: gpcb_plugin.h:60
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
bool FootprintLibDelete(const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Function FootprintLibDelete deletes an existing footprint library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.
Class PLUGIN is a base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:266
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:99
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, const PROPERTIES *aProperties=NULL) override
Return a list of footprint names contained within the library at aLibraryPath.
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const PROPERTIES *aProperties=NULL) override
Function FootprintDelete deletes aFootprintName from the library at aLibraryPath. ...
wxString m_error
for throwing exceptions
Definition: gpcb_plugin.h:95
wxString m_filename
for saves only, name is in m_reader for loads
Definition: gpcb_plugin.h:100