KiCad PCB EDA Suite
config_params.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) 2004 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2008-2011 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef CONFIG_PARAMS_H_
27#define CONFIG_PARAMS_H_
28
29#include <set>
30#include <limits>
31
32#include <wx/confbase.h>
33#include <wx/fileconf.h>
34#include <boost/ptr_container/ptr_vector.hpp>
35#include <gal/color4d.h>
36
37using KIGFX::COLOR4D;
38
39
50void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue );
51
52
70};
71
72
82{
83public:
84 PARAM_CFG( const wxString& ident, const paramcfg_id type, const wxChar* group = nullptr,
85 const wxString& legacy_ident = wxEmptyString );
86 virtual ~PARAM_CFG() {}
87
93 virtual void ReadParam( wxConfigBase* aConfig ) const {};
94
100 virtual void SaveParam( wxConfigBase* aConfig ) const {};
101
102 wxString m_Ident;
104 wxString m_Group;
105 bool m_Setup;
106
107 // If the m_Ident keyword isn't found, fall back and read values from m_Ident_legacy.
108 // Note that values are always written to the current, non-legacy keyword.
110};
111
112
117{
118public:
119 PARAM_CFG_INT( const wxString& ident, int* ptparam, int default_val = 0,
120 int min = std::numeric_limits<int>::min(),
121 int max = std::numeric_limits<int>::max(),
122 const wxChar* group = nullptr,
123 const wxString& legacy_ident = wxEmptyString );
124 PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam, int default_val = 0,
125 int min = std::numeric_limits<int>::min(),
126 int max = std::numeric_limits<int>::max(),
127 const wxChar* group = nullptr,
128 const wxString& legacy_ident = wxEmptyString );
129
130 virtual void ReadParam( wxConfigBase* aConfig ) const override;
131 virtual void SaveParam( wxConfigBase* aConfig ) const override;
132
136};
137
145{
146public:
147 PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam, int default_val = 0,
148 int min = std::numeric_limits<int>::min(),
149 int max = std::numeric_limits<int>::max(),
150 const wxChar* group = nullptr, double aBiu2cfgunit = 1.0,
151 const wxString& legacy_ident = wxEmptyString );
152 PARAM_CFG_INT_WITH_SCALE( bool insetup, const wxString& ident, int* ptparam,
153 int default_val = 0,
154 int min = std::numeric_limits<int>::min(),
155 int max = std::numeric_limits<int>::max(),
156 const wxChar* group = nullptr, double aBiu2cfgunit = 1.0,
157 const wxString& legacy_ident = wxEmptyString );
158
159 virtual void ReadParam( wxConfigBase* aConfig ) const override;
160 virtual void SaveParam( wxConfigBase* aConfig ) const override;
161
162public:
164};
165
166
171{
172public:
173 PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
174 double default_val = 0.0, double min = 0.0, double max = 10000.0,
175 const wxChar* group = nullptr );
176 PARAM_CFG_DOUBLE( bool Insetup, const wxString& ident, double* ptparam,
177 double default_val = 0.0, double min = 0.0, double max = 10000.0,
178 const wxChar* group = nullptr );
179
180 virtual void ReadParam( wxConfigBase* aConfig ) const override;
181 virtual void SaveParam( wxConfigBase* aConfig ) const override;
182
183 double* m_Pt_param;
184 double m_Default;
185 double m_Min, m_Max;
186};
187
188
193{
194public:
195 PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
196 int default_val = false, const wxChar* group = nullptr,
197 const wxString& legacy_ident = wxEmptyString );
198 PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
199 int default_val = false, const wxChar* group = nullptr,
200 const wxString& legacy_ident = wxEmptyString );
201
202 virtual void ReadParam( wxConfigBase* aConfig ) const override;
203 virtual void SaveParam( wxConfigBase* aConfig ) const override;
204
207};
208
209
214{
215public:
216 PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group = nullptr );
217
218 PARAM_CFG_WXSTRING( bool Insetup,
219 const wxString& ident,
220 wxString* ptparam,
221 const wxString& default_val = wxEmptyString,
222 const wxChar* group = nullptr );
223
224 virtual void ReadParam( wxConfigBase* aConfig ) const override;
225 virtual void SaveParam( wxConfigBase* aConfig ) const override;
226
227 wxString* m_Pt_param;
228 wxString m_default;
229};
230
231
237{
238public:
239 PARAM_CFG_WXSTRING_SET( const wxString& ident, std::set<wxString>* ptparam,
240 const wxChar* group = nullptr );
241
242 PARAM_CFG_WXSTRING_SET( bool Insetup,
243 const wxString& ident,
244 std::set<wxString>* ptparam,
245 const wxChar* group = nullptr );
246
247 virtual void ReadParam( wxConfigBase* aConfig ) const override;
248 virtual void SaveParam( wxConfigBase* aConfig ) const override;
249
250 std::set<wxString>* m_Pt_param;
251};
252
253
260{
261public:
262 PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam,
263 const wxChar* group = nullptr );
264 virtual void ReadParam( wxConfigBase* aConfig ) const override;
265 virtual void SaveParam( wxConfigBase* aConfig ) const override;
266
267 wxString* m_Pt_param;
268};
269
270
272{
273public:
274 wxArrayString* m_Pt_param;
275
276public:
277 PARAM_CFG_LIBNAME_LIST( const wxChar* ident, wxArrayString* ptparam,
278 const wxChar* group = nullptr );
279
280 virtual void ReadParam( wxConfigBase* aConfig ) const override;
281 virtual void SaveParam( wxConfigBase* aConfig ) const override;
282};
283
284
293void wxConfigSaveSetups( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList );
294
305void wxConfigSaveParams( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList,
306 const wxString& aGroup );
307
316void wxConfigLoadSetups( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList );
317
327void wxConfigLoadParams( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList,
328 const wxString& aGroup );
329
330
331#endif // CONFIG_PARAMS_H_
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Configuration object for booleans.
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
bool * m_Pt_param
Pointer to the parameter value.
PARAM_CFG_BOOL(const wxString &ident, bool *ptparam, int default_val=false, const wxChar *group=nullptr, const wxString &legacy_ident=wxEmptyString)
int m_Default
The default value of the parameter.
Configuration object for double precision floating point numbers.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
double m_Max
Minimum and maximum values of the param type.
PARAM_CFG_DOUBLE(const wxString &ident, double *ptparam, double default_val=0.0, double min=0.0, double max=10000.0, const wxChar *group=nullptr)
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
double * m_Pt_param
Pointer to the parameter value.
double m_Default
The default value of the parameter.
Configuration object for a file name object.
wxString * m_Pt_param
Pointer to the parameter value.
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
PARAM_CFG_FILENAME(const wxString &ident, wxString *ptparam, const wxChar *group=nullptr)
Configuration for integers with unit conversion.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
PARAM_CFG_INT_WITH_SCALE(const wxString &ident, int *ptparam, int default_val=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), const wxChar *group=nullptr, double aBiu2cfgunit=1.0, const wxString &legacy_ident=wxEmptyString)
double m_BIU_to_cfgunit
the factor to convert the saved value in internal value
Configuration object for integers.
int m_Max
Minimum and maximum values of the param type.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
PARAM_CFG_INT(const wxString &ident, int *ptparam, int default_val=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), const wxChar *group=nullptr, const wxString &legacy_ident=wxEmptyString)
int m_Default
The default value of the parameter.
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
int * m_Pt_param
Pointer to the parameter value.
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
wxArrayString * m_Pt_param
Pointer to the parameter value.
PARAM_CFG_LIBNAME_LIST(const wxChar *ident, wxArrayString *ptparam, const wxChar *group=nullptr)
Configuration object for a set of wxString objects.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
std::set< wxString > * m_Pt_param
Pointer to the parameter value.
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
PARAM_CFG_WXSTRING_SET(const wxString &ident, std::set< wxString > *ptparam, const wxChar *group=nullptr)
Configuration object for wxString objects.
virtual void ReadParam(wxConfigBase *aConfig) const override
Read the value of the parameter stored in aConfig.
wxString * m_Pt_param
Pointer to the parameter value.
virtual void SaveParam(wxConfigBase *aConfig) const override
Save the value of the parameter stored in aConfig.
PARAM_CFG_WXSTRING(const wxString &ident, wxString *ptparam, const wxChar *group=nullptr)
wxString m_default
The default value of the parameter.
A base class which establishes the interface functions ReadParam and SaveParam, which are implemented...
Definition: config_params.h:82
virtual ~PARAM_CFG()
Definition: config_params.h:86
virtual void ReadParam(wxConfigBase *aConfig) const
Read the value of the parameter stored in aConfig.
Definition: config_params.h:93
wxString m_Ident_legacy
paramcfg_id m_Type
Type of parameter.
wxString m_Ident
Keyword in config data.
wxString m_Group
Group name (this is like a path in the config data)
PARAM_CFG(const wxString &ident, const paramcfg_id type, const wxChar *group=nullptr, const wxString &legacy_ident=wxEmptyString)
virtual void SaveParam(wxConfigBase *aConfig) const
Save the value of the parameter stored in aConfig.
bool m_Setup
Install or Project based parameter, true == install.
void wxConfigSaveSetups(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
Writes aList of PARAM_CFG objects to aCfg.
void wxConfigSaveParams(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
Write aList of PARAM_CFG objects aCfg.
void wxConfigLoadParams(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
Use aList of PARAM_CFG objects to load configuration values from aCfg.
void wxConfigLoadSetups(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
Use aList of PARAM_CFG object to load configuration values from aCfg.
paramcfg_id
Type of parameter in the configuration file.
Definition: config_params.h:54
@ PARAM_WXSTRING
Definition: config_params.h:60
@ PARAM_LIBNAME_LIST
Definition: config_params.h:59
@ PARAM_INT_WITH_SCALE
Definition: config_params.h:56
@ PARAM_DIFFPAIRDIMENSIONS
Definition: config_params.h:67
@ PARAM_LAYERS
Definition: config_params.h:64
@ PARAM_INT
Definition: config_params.h:55
@ PARAM_TRACKWIDTHS
Definition: config_params.h:65
@ PARAM_FILENAME
Definition: config_params.h:62
@ PARAM_DOUBLE
Definition: config_params.h:57
@ PARAM_COMMAND_ERASE
Definition: config_params.h:63
@ PARAM_NETCLASSES
Definition: config_params.h:68
@ PARAM_SEVERITIES
Definition: config_params.h:69
@ PARAM_BOOL
Definition: config_params.h:58
@ PARAM_WXSTRING_SET
Definition: config_params.h:61
@ PARAM_VIADIMENSIONS
Definition: config_params.h:66
void ConfigBaseWriteDouble(wxConfigBase *aConfig, const wxString &aKey, double aValue)
A helper function to write doubles in configuration file.