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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef CONFIG_PARAMS_H_
23#define CONFIG_PARAMS_H_
24
25#include <kicommon.h>
26#include <set>
27#include <limits>
28
29#include <wx/confbase.h>
30#include <wx/fileconf.h>
31#include <boost/ptr_container/ptr_vector.hpp>
32
33
44KICOMMON_API void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue );
45
46
65
66
76{
77public:
78 PARAM_CFG( const wxString& ident, const paramcfg_id type, const wxChar* group = nullptr,
79 const wxString& legacy_ident = wxEmptyString );
80 virtual ~PARAM_CFG() {}
81
87 virtual void ReadParam( wxConfigBase* aConfig ) const {};
88
94 virtual void SaveParam( wxConfigBase* aConfig ) const {};
95
96 wxString m_Ident;
98 wxString m_Group;
99 bool m_Setup;
100
101 // If the m_Ident keyword isn't found, fall back and read values from m_Ident_legacy.
102 // Note that values are always written to the current, non-legacy keyword.
104};
105
106
111{
112public:
113 PARAM_CFG_INT( const wxString& ident, int* ptparam, int default_val = 0,
114 int min = std::numeric_limits<int>::min(),
115 int max = std::numeric_limits<int>::max(),
116 const wxChar* group = nullptr,
117 const wxString& legacy_ident = wxEmptyString );
118 PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam, int default_val = 0,
119 int min = std::numeric_limits<int>::min(),
120 int max = std::numeric_limits<int>::max(),
121 const wxChar* group = nullptr,
122 const wxString& legacy_ident = wxEmptyString );
123
124 virtual void ReadParam( wxConfigBase* aConfig ) const override;
125 virtual void SaveParam( wxConfigBase* aConfig ) const override;
126
130};
131
139{
140public:
141 PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam, int default_val = 0,
142 int min = std::numeric_limits<int>::min(),
143 int max = std::numeric_limits<int>::max(),
144 const wxChar* group = nullptr, double aBiu2cfgunit = 1.0,
145 const wxString& legacy_ident = wxEmptyString );
146 PARAM_CFG_INT_WITH_SCALE( bool insetup, const wxString& ident, int* ptparam,
147 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
153 virtual void ReadParam( wxConfigBase* aConfig ) const override;
154 virtual void SaveParam( wxConfigBase* aConfig ) const override;
155
156public:
158};
159
160
165{
166public:
167 PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
168 double default_val = 0.0, double min = 0.0, double max = 10000.0,
169 const wxChar* group = nullptr );
170 PARAM_CFG_DOUBLE( bool Insetup, const wxString& ident, double* ptparam,
171 double default_val = 0.0, double min = 0.0, double max = 10000.0,
172 const wxChar* group = nullptr );
173
174 virtual void ReadParam( wxConfigBase* aConfig ) const override;
175 virtual void SaveParam( wxConfigBase* aConfig ) const override;
176
177 double* m_Pt_param;
178 double m_Default;
179 double m_Min, m_Max;
180};
181
182
187{
188public:
189 PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
190 int default_val = false, const wxChar* group = nullptr,
191 const wxString& legacy_ident = wxEmptyString );
192 PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
193 int default_val = false, const wxChar* group = nullptr,
194 const wxString& legacy_ident = wxEmptyString );
195
196 virtual void ReadParam( wxConfigBase* aConfig ) const override;
197 virtual void SaveParam( wxConfigBase* aConfig ) const override;
198
201};
202
203
208{
209public:
210 PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group = nullptr );
211
212 PARAM_CFG_WXSTRING( bool Insetup,
213 const wxString& ident,
214 wxString* ptparam,
215 const wxString& default_val = wxEmptyString,
216 const wxChar* group = nullptr );
217
218 virtual void ReadParam( wxConfigBase* aConfig ) const override;
219 virtual void SaveParam( wxConfigBase* aConfig ) const override;
220
221 wxString* m_Pt_param;
222 wxString m_default;
223};
224
225
231{
232public:
233 PARAM_CFG_WXSTRING_SET( const wxString& ident, std::set<wxString>* ptparam,
234 const wxChar* group = nullptr );
235
236 PARAM_CFG_WXSTRING_SET( bool Insetup,
237 const wxString& ident,
238 std::set<wxString>* ptparam,
239 const wxChar* group = nullptr );
240
241 virtual void ReadParam( wxConfigBase* aConfig ) const override;
242 virtual void SaveParam( wxConfigBase* aConfig ) const override;
243
244 std::set<wxString>* m_Pt_param;
245};
246
247
254{
255public:
256 PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam,
257 const wxChar* group = nullptr );
258 virtual void ReadParam( wxConfigBase* aConfig ) const override;
259 virtual void SaveParam( wxConfigBase* aConfig ) const override;
260
261 wxString* m_Pt_param;
262};
263
264
266{
267public:
268 wxArrayString* m_Pt_param;
269
270public:
271 PARAM_CFG_LIBNAME_LIST( const wxChar* ident, wxArrayString* ptparam,
272 const wxChar* group = nullptr );
273
274 virtual void ReadParam( wxConfigBase* aConfig ) const override;
275 virtual void SaveParam( wxConfigBase* aConfig ) const override;
276};
277
278
287KICOMMON_API void wxConfigSaveSetups( wxConfigBase* aCfg, const std::vector<std::unique_ptr<PARAM_CFG>>& aList );
288
299KICOMMON_API void wxConfigSaveParams( wxConfigBase* aCfg, const std::vector<std::unique_ptr<PARAM_CFG>>& aList,
300 const wxString& aGroup );
301
310KICOMMON_API void wxConfigLoadSetups( wxConfigBase* aCfg, const std::vector<std::unique_ptr<PARAM_CFG>>& aList );
311
321KICOMMON_API void wxConfigLoadParams( wxConfigBase* aCfg, const std::vector<std::unique_ptr<PARAM_CFG>>& aList,
322 const wxString& aGroup );
323
324
325#endif // CONFIG_PARAMS_H_
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.
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.
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)
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
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)
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)
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.
virtual ~PARAM_CFG()
virtual void ReadParam(wxConfigBase *aConfig) const
Read the value of the parameter stored in aConfig.
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.
KICOMMON_API void wxConfigLoadSetups(wxConfigBase *aCfg, const std::vector< std::unique_ptr< PARAM_CFG > > &aList)
Use aList of PARAM_CFG object to load configuration values from aCfg.
KICOMMON_API void wxConfigLoadParams(wxConfigBase *aCfg, const std::vector< std::unique_ptr< PARAM_CFG > > &aList, const wxString &aGroup)
Use aList of PARAM_CFG objects to load configuration values from aCfg.
KICOMMON_API void ConfigBaseWriteDouble(wxConfigBase *aConfig, const wxString &aKey, double aValue)
A helper function to write doubles in configuration file.
KICOMMON_API void wxConfigSaveSetups(wxConfigBase *aCfg, const std::vector< std::unique_ptr< PARAM_CFG > > &aList)
Writes aList of PARAM_CFG objects to aCfg.
paramcfg_id
Type of parameter in the configuration file.
@ PARAM_WXSTRING
@ PARAM_LIBNAME_LIST
@ PARAM_INT_WITH_SCALE
@ PARAM_DIFFPAIRDIMENSIONS
@ PARAM_LAYERS
@ PARAM_INT
@ PARAM_TRACKWIDTHS
@ PARAM_FILENAME
@ PARAM_DOUBLE
@ PARAM_COMMAND_ERASE
@ PARAM_NETCLASSES
@ PARAM_SEVERITIES
@ PARAM_BOOL
@ PARAM_WXSTRING_SET
@ PARAM_VIADIMENSIONS
KICOMMON_API void wxConfigSaveParams(wxConfigBase *aCfg, const std::vector< std::unique_ptr< PARAM_CFG > > &aList, const wxString &aGroup)
Write aList of PARAM_CFG objects aCfg.
#define KICOMMON_API
Definition kicommon.h:27