KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <kicommon.h>
30#include <set>
31#include <limits>
32
33#include <wx/confbase.h>
34#include <wx/fileconf.h>
35#include <boost/ptr_container/ptr_vector.hpp>
36
37
48KICOMMON_API void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue );
49
50
68};
69
70
80{
81public:
82 PARAM_CFG( const wxString& ident, const paramcfg_id type, const wxChar* group = nullptr,
83 const wxString& legacy_ident = wxEmptyString );
84 virtual ~PARAM_CFG() {}
85
91 virtual void ReadParam( wxConfigBase* aConfig ) const {};
92
98 virtual void SaveParam( wxConfigBase* aConfig ) const {};
99
100 wxString m_Ident;
102 wxString m_Group;
103 bool m_Setup;
104
105 // If the m_Ident keyword isn't found, fall back and read values from m_Ident_legacy.
106 // Note that values are always written to the current, non-legacy keyword.
108};
109
110
115{
116public:
117 PARAM_CFG_INT( const wxString& ident, int* ptparam, int default_val = 0,
118 int min = std::numeric_limits<int>::min(),
119 int max = std::numeric_limits<int>::max(),
120 const wxChar* group = nullptr,
121 const wxString& legacy_ident = wxEmptyString );
122 PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam, int default_val = 0,
123 int min = std::numeric_limits<int>::min(),
124 int max = std::numeric_limits<int>::max(),
125 const wxChar* group = nullptr,
126 const wxString& legacy_ident = wxEmptyString );
127
128 virtual void ReadParam( wxConfigBase* aConfig ) const override;
129 virtual void SaveParam( wxConfigBase* aConfig ) const override;
130
132 int m_Min, m_Max;
134};
135
143{
144public:
145 PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam, int default_val = 0,
146 int min = std::numeric_limits<int>::min(),
147 int max = std::numeric_limits<int>::max(),
148 const wxChar* group = nullptr, double aBiu2cfgunit = 1.0,
149 const wxString& legacy_ident = wxEmptyString );
150 PARAM_CFG_INT_WITH_SCALE( bool insetup, const wxString& ident, int* ptparam,
151 int default_val = 0,
152 int min = std::numeric_limits<int>::min(),
153 int max = std::numeric_limits<int>::max(),
154 const wxChar* group = nullptr, double aBiu2cfgunit = 1.0,
155 const wxString& legacy_ident = wxEmptyString );
156
157 virtual void ReadParam( wxConfigBase* aConfig ) const override;
158 virtual void SaveParam( wxConfigBase* aConfig ) const override;
159
160public:
162};
163
164
169{
170public:
171 PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
172 double default_val = 0.0, double min = 0.0, double max = 10000.0,
173 const wxChar* group = nullptr );
174 PARAM_CFG_DOUBLE( bool Insetup, const wxString& ident, double* ptparam,
175 double default_val = 0.0, double min = 0.0, double max = 10000.0,
176 const wxChar* group = nullptr );
177
178 virtual void ReadParam( wxConfigBase* aConfig ) const override;
179 virtual void SaveParam( wxConfigBase* aConfig ) const override;
180
181 double* m_Pt_param;
182 double m_Default;
183 double m_Min, m_Max;
184};
185
186
191{
192public:
193 PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
194 int default_val = false, const wxChar* group = nullptr,
195 const wxString& legacy_ident = wxEmptyString );
196 PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
197 int default_val = false, const wxChar* group = nullptr,
198 const wxString& legacy_ident = wxEmptyString );
199
200 virtual void ReadParam( wxConfigBase* aConfig ) const override;
201 virtual void SaveParam( wxConfigBase* aConfig ) const override;
202
205};
206
207
212{
213public:
214 PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group = nullptr );
215
216 PARAM_CFG_WXSTRING( bool Insetup,
217 const wxString& ident,
218 wxString* ptparam,
219 const wxString& default_val = wxEmptyString,
220 const wxChar* group = nullptr );
221
222 virtual void ReadParam( wxConfigBase* aConfig ) const override;
223 virtual void SaveParam( wxConfigBase* aConfig ) const override;
224
225 wxString* m_Pt_param;
226 wxString m_default;
227};
228
229
235{
236public:
237 PARAM_CFG_WXSTRING_SET( const wxString& ident, std::set<wxString>* ptparam,
238 const wxChar* group = nullptr );
239
240 PARAM_CFG_WXSTRING_SET( bool Insetup,
241 const wxString& ident,
242 std::set<wxString>* ptparam,
243 const wxChar* group = nullptr );
244
245 virtual void ReadParam( wxConfigBase* aConfig ) const override;
246 virtual void SaveParam( wxConfigBase* aConfig ) const override;
247
248 std::set<wxString>* m_Pt_param;
249};
250
251
258{
259public:
260 PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam,
261 const wxChar* group = nullptr );
262 virtual void ReadParam( wxConfigBase* aConfig ) const override;
263 virtual void SaveParam( wxConfigBase* aConfig ) const override;
264
265 wxString* m_Pt_param;
266};
267
268
270{
271public:
272 wxArrayString* m_Pt_param;
273
274public:
275 PARAM_CFG_LIBNAME_LIST( const wxChar* ident, wxArrayString* ptparam,
276 const wxChar* group = nullptr );
277
278 virtual void ReadParam( wxConfigBase* aConfig ) const override;
279 virtual void SaveParam( wxConfigBase* aConfig ) const override;
280};
281
282
291KICOMMON_API void wxConfigSaveSetups( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList );
292
303KICOMMON_API void wxConfigSaveParams( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList,
304 const wxString& aGroup );
305
314KICOMMON_API void wxConfigLoadSetups( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList );
315
325KICOMMON_API void wxConfigLoadParams( wxConfigBase* aCfg, const std::vector<PARAM_CFG*>& aList,
326 const wxString& aGroup );
327
328
329#endif // CONFIG_PARAMS_H_
Configuration object for booleans.
bool * m_Pt_param
Pointer to the parameter value.
int m_Default
The default value of the parameter.
Configuration object for double precision floating point numbers.
double m_Max
Minimum and maximum values of the param type.
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.
Configuration for integers with unit conversion.
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.
int m_Default
The default value of the parameter.
int * m_Pt_param
Pointer to the parameter value.
wxArrayString * m_Pt_param
Pointer to the parameter value.
Configuration object for a set of wxString objects.
std::set< wxString > * m_Pt_param
Pointer to the parameter value.
Configuration object for wxString objects.
wxString * m_Pt_param
Pointer to the parameter value.
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:80
virtual ~PARAM_CFG()
Definition: config_params.h:84
virtual void ReadParam(wxConfigBase *aConfig) const
Read the value of the parameter stored in aConfig.
Definition: config_params.h:91
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)
virtual void SaveParam(wxConfigBase *aConfig) const
Save the value of the parameter stored in aConfig.
Definition: config_params.h:98
bool m_Setup
Install or Project based parameter, true == install.
KICOMMON_API void wxConfigSaveSetups(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
Writes aList of PARAM_CFG objects to aCfg.
KICOMMON_API void wxConfigSaveParams(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
Write aList of PARAM_CFG objects aCfg.
KICOMMON_API void ConfigBaseWriteDouble(wxConfigBase *aConfig, const wxString &aKey, double aValue)
A helper function to write doubles in configuration file.
paramcfg_id
Type of parameter in the configuration file.
Definition: config_params.h:52
@ PARAM_WXSTRING
Definition: config_params.h:58
@ PARAM_LIBNAME_LIST
Definition: config_params.h:57
@ PARAM_INT_WITH_SCALE
Definition: config_params.h:54
@ PARAM_DIFFPAIRDIMENSIONS
Definition: config_params.h:65
@ PARAM_LAYERS
Definition: config_params.h:62
@ PARAM_INT
Definition: config_params.h:53
@ PARAM_TRACKWIDTHS
Definition: config_params.h:63
@ PARAM_FILENAME
Definition: config_params.h:60
@ PARAM_DOUBLE
Definition: config_params.h:55
@ PARAM_COMMAND_ERASE
Definition: config_params.h:61
@ PARAM_NETCLASSES
Definition: config_params.h:66
@ PARAM_SEVERITIES
Definition: config_params.h:67
@ PARAM_BOOL
Definition: config_params.h:56
@ PARAM_WXSTRING_SET
Definition: config_params.h:59
@ PARAM_VIADIMENSIONS
Definition: config_params.h:64
KICOMMON_API 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.
KICOMMON_API void wxConfigLoadSetups(wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
Use aList of PARAM_CFG object to load configuration values from aCfg.
#define KICOMMON_API
Definition: kicommon.h:28