KiCad PCB EDA Suite
bom_plugins.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) 2018 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
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 3
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  * https://www.gnu.org/licenses/gpl-3.0.html
20  * or you may search the http://www.gnu.org website for the version 3 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 
25 #ifndef BOM_PLUGINS_H
26 #define BOM_PLUGINS_H
27 
28 #include <wx/arrstr.h>
29 #include <wx/file.h>
30 #include <wx/filename.h>
31 
32 #include <memory>
33 
38 {
39 public:
40  typedef std::unique_ptr<BOM_PLUGIN> PTR;
41 
46  BOM_PLUGIN( const wxString& aFile );
47 
52  bool IsOk() { return m_isOk; }
53 
58  static bool IsPlugin( const wxString& aFile );
59 
63  const wxString& GetInfo() const
64  {
65  return m_info;
66  }
67 
71  const wxFileName& GetFile() const
72  {
73  return m_file;
74  }
75 
79  const wxString& GetName() const
80  {
81  return m_name;
82  }
83 
88  void SetName( const wxString& aName )
89  {
90  m_name = aName;
91  }
92 
96  const wxString& GetCommand() const
97  {
98  return m_cmd;
99  }
100 
104  void SetCommand( const wxString& aCommand )
105  {
106  m_cmd = aCommand;
107  }
108 
112  wxArrayString& Options()
113  {
114  return m_options;
115  }
116 
117 protected:
122  wxString readHeader( const wxString& aEndSection );
123 
125  bool m_isOk;
126 
128  const wxFileName m_file;
129 
131  wxString m_name;
132 
134  wxString m_cmd;
135 
137  wxString m_info;
138 
140  wxArrayString m_options;
141 };
142 
143 #endif /* BOM_PLUGINS_H */
wxString m_info
Description of the plugin (normally from the plugin header)
Definition: bom_plugins.h:137
bool IsOk()
Returns true if the plugin is ready to work, i.e.
Definition: bom_plugins.h:52
wxString readHeader(const wxString &aEndSection)
Reads the plugin file header.
Definition: bom_plugins.cpp:93
const wxString & GetCommand() const
Returns the command to execute the plugin.
Definition: bom_plugins.h:96
wxArrayString m_options
Plugin specific options
Definition: bom_plugins.h:140
Class representing a Bill of Material output plugin.
Definition: bom_plugins.h:37
wxString m_cmd
Command to execute the plugin
Definition: bom_plugins.h:134
const wxFileName m_file
Path to the plugin
Definition: bom_plugins.h:128
const wxFileName & GetFile() const
Returns the file name of the plugin.
Definition: bom_plugins.h:71
wxString m_name
User customisable name
Definition: bom_plugins.h:131
bool m_isOk
true if the plugin is working (i.e. if the plugin file exists and was read
Definition: bom_plugins.h:125
const wxString & GetInfo() const
Returns plugin description stored in the plugin header file (if available).
Definition: bom_plugins.h:63
const wxString & GetName() const
Returns the customisable plugin name.
Definition: bom_plugins.h:79
static bool IsPlugin(const wxString &aFile)
Returns true if a file name matches a recognized plugin format.
Definition: bom_plugins.cpp:78
std::unique_ptr< BOM_PLUGIN > PTR
Definition: bom_plugins.h:40
void SetName(const wxString &aName)
Sets the customisable plugin name.
Definition: bom_plugins.h:88
wxArrayString & Options()
Accessor to array of options.
Definition: bom_plugins.h:112
BOM_PLUGIN(const wxString &aFile)
Constructor.
Definition: bom_plugins.cpp:27
void SetCommand(const wxString &aCommand)
Sets the command to execute the plugin.
Definition: bom_plugins.h:104