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  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 3
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * https://www.gnu.org/licenses/gpl-3.0.html
22  * or you may search the http://www.gnu.org website for the version 3 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef BOM_GENERATOR_HANDLERS_H
28 #define BOM_GENERATOR_HANDLERS_H
29 
30 #include <wx/arrstr.h>
31 #include <wx/file.h>
32 #include <wx/filename.h>
33 
34 #include <memory>
35 
36 extern const wxChar BOM_TRACE[];
37 
46 {
47 public:
48  typedef std::unique_ptr<BOM_GENERATOR_HANDLER> PTR;
49 
53  BOM_GENERATOR_HANDLER( const wxString& aFile );
54 
58  bool IsOk() { return m_isOk; }
59 
65  static bool IsValidGenerator( const wxString& aFile );
66 
70  const wxString& GetInfo() const
71  {
72  return m_info;
73  }
74 
78  const wxFileName& GetFile() const
79  {
80  return m_file;
81  }
82 
83  wxString GetStoredPath() const { return m_storedPath; }
84 
93  wxFileName FindFilePath() const;
94 
98  const wxString& GetName() const
99  {
100  return m_name;
101  }
102 
108  void SetName( const wxString& aName )
109  {
110  m_name = aName;
111  }
112 
116  const wxString& GetCommand() const
117  {
118  return m_cmd;
119  }
120 
124  void SetCommand( const wxString& aCommand )
125  {
126  m_cmd = aCommand;
127  }
128 
132  wxArrayString& Options()
133  {
134  return m_options;
135  }
136 
137 protected:
143  wxString readHeader( const wxString& aEndSection );
144 
151  static wxString getOutputExtension( const wxString& aHeader );
152 
154  bool m_isOk;
155 
157  wxFileName m_file;
158 
160  const wxString m_storedPath;
161 
163  wxString m_name;
164 
166  wxString m_cmd;
167 
169  wxString m_info;
170 
172  wxArrayString m_options;
173 };
174 
175 #endif /* BOM_GENERATOR_HANDLERS_H */
wxArrayString & Options()
Accessor to array of options.
Definition: bom_plugins.h:132
std::unique_ptr< BOM_GENERATOR_HANDLER > PTR
Definition: bom_plugins.h:48
void SetCommand(const wxString &aCommand)
Set the command to execute the plugin.
Definition: bom_plugins.h:124
const wxFileName & GetFile() const
Return the file name of the plugin.
Definition: bom_plugins.h:78
wxString readHeader(const wxString &aEndSection)
Read the plugin file header.
const wxString & GetInfo() const
Return plugin description stored in the plugin header file (if available).
Definition: bom_plugins.h:70
wxFileName m_file
Path to the plugin stored in config (can be absolute or just a filename)
Definition: bom_plugins.h:157
wxString m_cmd
Description of the plugin (normally from the plugin header)
Definition: bom_plugins.h:166
bool IsOk()
Return true if the plugin is ready to work, i.e.
Definition: bom_plugins.h:58
Bill of material output generator.
Definition: bom_plugins.h:45
wxFileName FindFilePath() const
Returns the calculated path to the plugin: if the path is already absolute and exists,...
static bool IsValidGenerator(const wxString &aFile)
Return true if a file name matches a recognized plugin format.
Definition: bom_plugins.cpp:95
void SetName(const wxString &aName)
Set the customisable plugin name.
Definition: bom_plugins.h:108
BOM_GENERATOR_HANDLER(const wxString &aFile)
Definition: bom_plugins.cpp:34
static wxString getOutputExtension(const wxString &aHeader)
Extracts the output BOM file's extension, including the '.
wxString m_name
Command to execute the plugin.
Definition: bom_plugins.h:163
const wxString & GetCommand() const
Return the command to execute the plugin.
Definition: bom_plugins.h:116
const wxString m_storedPath
User customisable name.
Definition: bom_plugins.h:160
wxString m_info
Plugin specific options.
Definition: bom_plugins.h:169
wxString GetStoredPath() const
Definition: bom_plugins.h:83
bool m_isOk
Path to the plugin.
Definition: bom_plugins.h:154
wxArrayString m_options
Definition: bom_plugins.h:172
const wxString & GetName() const
Return the customisable plugin name.
Definition: bom_plugins.h:98
const wxChar BOM_TRACE[]
Definition: bom_plugins.cpp:31