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  static bool IsPlugin( const wxString& aFile );
53 
57  const wxString& GetInfo() const
58  {
59  return m_info;
60  }
61 
65  const wxFileName& GetFile() const
66  {
67  return m_file;
68  }
69 
73  const wxString& GetName() const
74  {
75  return m_name;
76  }
77 
82  void SetName( const wxString& aName )
83  {
84  m_name = aName;
85  }
86 
90  const wxString& GetCommand() const
91  {
92  return m_cmd;
93  }
94 
98  void SetCommand( const wxString& aCommand )
99  {
100  m_cmd = aCommand;
101  }
102 
106  wxArrayString& Options()
107  {
108  return m_options;
109  }
110 
111 protected:
116  wxString readHeader( const wxString& aEndSection );
117 
119  const wxFileName m_file;
120 
122  wxString m_name;
123 
125  wxString m_cmd;
126 
128  wxString m_info;
129 
131  wxArrayString m_options;
132 };
133 
134 #endif /* BOM_PLUGINS_H */
const wxString & GetName() const
Returns the customisable plugin name.
Definition: bom_plugins.h:73
wxString m_info
Description of the plugin (normally from the plugin header)
Definition: bom_plugins.h:128
wxString readHeader(const wxString &aEndSection)
Reads the plugin file header.
Definition: bom_plugins.cpp:86
wxArrayString m_options
Plugin specific options
Definition: bom_plugins.h:131
const wxFileName & GetFile() const
Returns the file name of the plugin.
Definition: bom_plugins.h:65
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:125
const wxString & GetCommand() const
Returns the command to execute the plugin.
Definition: bom_plugins.h:90
const wxString & GetInfo() const
Returns plugin description stored in the plugin header file (if available).
Definition: bom_plugins.h:57
const wxFileName m_file
Path to the plugin
Definition: bom_plugins.h:119
wxString m_name
User customisable name
Definition: bom_plugins.h:122
static bool IsPlugin(const wxString &aFile)
Returns true if a file name matches a recognized plugin format.
Definition: bom_plugins.cpp:71
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:82
wxArrayString & Options()
Accessor to array of options.
Definition: bom_plugins.h:106
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:98