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:
51  BOM_GENERATOR_HANDLER( const wxString& aFile );
52 
56  bool IsOk() { return m_isOk; }
57 
63  static bool IsValidGenerator( const wxString& aFile );
64 
68  const wxString& GetInfo() const
69  {
70  return m_info;
71  }
72 
76  const wxFileName& GetFile() const
77  {
78  return m_file;
79  }
80 
81  wxString GetStoredPath() const { return m_storedPath; }
82 
91  wxFileName FindFilePath() const;
92 
96  const wxString& GetName() const
97  {
98  return m_name;
99  }
100 
106  void SetName( const wxString& aName )
107  {
108  m_name = aName;
109  }
110 
114  const wxString& GetCommand() const
115  {
116  return m_cmd;
117  }
118 
122  void SetCommand( const wxString& aCommand )
123  {
124  m_cmd = aCommand;
125  }
126 
130  wxArrayString& Options()
131  {
132  return m_options;
133  }
134 
135 protected:
141  wxString readHeader( const wxString& aEndSection );
142 
149  static wxString getOutputExtension( const wxString& aHeader );
150 
152  bool m_isOk;
153 
155  wxFileName m_file;
156 
158  const wxString m_storedPath;
159 
161  wxString m_name;
162 
164  wxString m_cmd;
165 
167  wxString m_info;
168 
170  wxArrayString m_options;
171 };
172 
173 #endif /* BOM_GENERATOR_HANDLERS_H */
wxArrayString & Options()
Accessor to array of options.
Definition: bom_plugins.h:130
void SetCommand(const wxString &aCommand)
Set the command to execute the plugin.
Definition: bom_plugins.h:122
const wxFileName & GetFile() const
Return the file name of the plugin.
Definition: bom_plugins.h:76
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:68
wxFileName m_file
Path to the plugin stored in config (can be absolute or just a filename)
Definition: bom_plugins.h:155
wxString m_cmd
Description of the plugin (normally from the plugin header)
Definition: bom_plugins.h:164
bool IsOk()
Return true if the plugin is ready to work, i.e.
Definition: bom_plugins.h:56
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.
void SetName(const wxString &aName)
Set the customisable plugin name.
Definition: bom_plugins.h:106
BOM_GENERATOR_HANDLER(const wxString &aFile)
Definition: bom_plugins.cpp:35
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:161
const wxString & GetCommand() const
Return the command to execute the plugin.
Definition: bom_plugins.h:114
const wxString m_storedPath
User customisable name.
Definition: bom_plugins.h:158
wxString m_info
Plugin specific options.
Definition: bom_plugins.h:167
wxString GetStoredPath() const
Definition: bom_plugins.h:81
bool m_isOk
Path to the plugin.
Definition: bom_plugins.h:152
wxArrayString m_options
Definition: bom_plugins.h:170
const wxString & GetName() const
Return the customisable plugin name.
Definition: bom_plugins.h:96
const wxChar BOM_TRACE[]
Definition: bom_plugins.cpp:32