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_GENERATOR_HANDLERS_H
26 #define BOM_GENERATOR_HANDLERS_H
27 
28 #include <wx/arrstr.h>
29 #include <wx/file.h>
30 #include <wx/filename.h>
31 
32 #include <memory>
33 
42 {
43 public:
44  typedef std::unique_ptr<BOM_GENERATOR_HANDLER> PTR;
45 
50  BOM_GENERATOR_HANDLER( const wxString& aFile );
51 
56  bool IsOk() { return m_isOk; }
57 
62  static bool IsValidGenerator( const wxString& aFile );
63 
67  const wxString& GetInfo() const
68  {
69  return m_info;
70  }
71 
75  const wxFileName& GetFile() const
76  {
77  return m_file;
78  }
79 
83  const wxString& GetName() const
84  {
85  return m_name;
86  }
87 
92  void SetName( const wxString& aName )
93  {
94  m_name = aName;
95  }
96 
100  const wxString& GetCommand() const
101  {
102  return m_cmd;
103  }
104 
108  void SetCommand( const wxString& aCommand )
109  {
110  m_cmd = aCommand;
111  }
112 
116  wxArrayString& Options()
117  {
118  return m_options;
119  }
120 
121 protected:
126  wxString readHeader( const wxString& aEndSection );
127 
129  bool m_isOk;
130 
132  const wxFileName m_file;
133 
135  wxString m_name;
136 
138  wxString m_cmd;
139 
141  wxString m_info;
142 
144  wxArrayString m_options;
145 };
146 
147 #endif /* BOM_GENERATOR_HANDLERS_H */
wxArrayString & Options()
Accessor to array of options.
Definition: bom_plugins.h:116
std::unique_ptr< BOM_GENERATOR_HANDLER > PTR
Definition: bom_plugins.h:44
void SetCommand(const wxString &aCommand)
Sets the command to execute the plugin.
Definition: bom_plugins.h:108
const wxFileName & GetFile() const
Returns the file name of the plugin.
Definition: bom_plugins.h:75
wxString readHeader(const wxString &aEndSection)
Reads the plugin file header.
Definition: bom_plugins.cpp:93
const wxString & GetInfo() const
Returns plugin description stored in the plugin header file (if available).
Definition: bom_plugins.h:67
wxString m_cmd
Command to execute the plugin
Definition: bom_plugins.h:138
bool IsOk()
Returns true if the plugin is ready to work, i.e.
Definition: bom_plugins.h:56
Class handling a Bill of Material output generator.
Definition: bom_plugins.h:41
static bool IsValidGenerator(const wxString &aFile)
Returns true if a file name matches a recognized plugin format.
Definition: bom_plugins.cpp:78
void SetName(const wxString &aName)
Sets the customisable plugin name.
Definition: bom_plugins.h:92
BOM_GENERATOR_HANDLER(const wxString &aFile)
Constructor.
Definition: bom_plugins.cpp:27
const wxFileName m_file
Path to the plugin
Definition: bom_plugins.h:132
wxString m_name
User customisable name
Definition: bom_plugins.h:135
const wxString & GetCommand() const
Returns the command to execute the plugin.
Definition: bom_plugins.h:100
wxString m_info
Description of the plugin (normally from the plugin header)
Definition: bom_plugins.h:141
bool m_isOk
true if the plugin is working (i.e. if the plugin file exists and was read
Definition: bom_plugins.h:129
wxArrayString m_options
Plugin specific options
Definition: bom_plugins.h:144
const wxString & GetName() const
Returns the customisable plugin name.
Definition: bom_plugins.h:83