KiCad PCB EDA Suite
parameters.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) 2020 Jon Evans <jon@craftyjon.com>
5  * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _PARAMETERS_H
22 #define _PARAMETERS_H
23 
24 #include <string>
25 #include <utility>
26 #include <math/util.h>
27 
28 #include <core/optional.h>
29 #include <settings/json_settings.h>
30 
31 
33 {
34 public:
35  PARAM_BASE( std::string aJsonPath, bool aReadOnly ) :
36  m_path( std::move( aJsonPath ) ),
37  m_readOnly( aReadOnly )
38  {}
39 
40  virtual ~PARAM_BASE() = default;
41 
47  virtual void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const = 0;
48 
53  virtual void Store( JSON_SETTINGS* aSettings ) const = 0;
54 
55  virtual void SetDefault() = 0;
56 
62  virtual bool MatchesFile( JSON_SETTINGS* aSettings ) const = 0;
63 
68  const std::string& GetJsonPath() const { return m_path; }
69 
70 protected:
74  std::string m_path;
75 
77  bool m_readOnly;
78 };
79 
80 
81 template<typename ValueType>
82 class PARAM : public PARAM_BASE
83 {
84 public:
85  PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
86  bool aReadOnly = false ) :
87  PARAM_BASE( aJsonPath, aReadOnly ),
88  m_min(),
89  m_max(),
90  m_use_minmax( false ),
91  m_ptr( aPtr ),
92  m_default( aDefault )
93  { }
94 
95  PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, ValueType aMin,
96  ValueType aMax, bool aReadOnly = false ) :
97  PARAM_BASE( aJsonPath, aReadOnly ),
98  m_min( aMin ),
99  m_max( aMax ),
100  m_use_minmax( true ),
101  m_ptr( aPtr ),
102  m_default( aDefault )
103  { }
104 
105  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
106  {
107  if( m_readOnly )
108  return;
109 
110  if( OPT<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
111  {
112  ValueType val = *optval;
113 
114  if( m_use_minmax )
115  {
116  if( m_max < val || val < m_min )
117  val = m_default;
118  }
119 
120  *m_ptr = val;
121  }
122  else if( aResetIfMissing )
123  *m_ptr = m_default;
124  }
125 
126  void Store( JSON_SETTINGS* aSettings ) const override
127  {
128  aSettings->Set<ValueType>( m_path, *m_ptr );
129  }
130 
131  ValueType GetDefault() const
132  {
133  return m_default;
134  }
135 
136  void SetDefault() override
137  {
138  *m_ptr = m_default;
139  }
140 
141  bool MatchesFile( JSON_SETTINGS* aSettings ) const override
142  {
143  if( OPT<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
144  return *optval == *m_ptr;
145 
146  return false;
147  }
148 
149 private:
150  ValueType m_min;
151  ValueType m_max;
153 
154 protected:
155  ValueType* m_ptr;
156  ValueType m_default;
157 };
158 
162 class PARAM_PATH : public PARAM<wxString>
163 {
164 public:
165  PARAM_PATH( const std::string& aJsonPath, wxString* aPtr, const wxString& aDefault,
166  bool aReadOnly = false ) :
167  PARAM( aJsonPath, aPtr, aDefault, aReadOnly )
168  { }
169 
170  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
171  {
172  if( m_readOnly )
173  return;
174 
175  PARAM::Load( aSettings, aResetIfMissing );
176 
177  *m_ptr = fromFileFormat( *m_ptr );
178  }
179 
180  void Store( JSON_SETTINGS* aSettings ) const override
181  {
182  aSettings->Set<wxString>( m_path, toFileFormat( *m_ptr ) );
183  }
184 
185  bool MatchesFile( JSON_SETTINGS* aSettings ) const override
186  {
187  if( OPT<wxString> optval = aSettings->Get<wxString>( m_path ) )
188  return fromFileFormat( *optval ) == *m_ptr;
189 
190  return false;
191  }
192 
193 private:
194  wxString toFileFormat( const wxString& aString ) const
195  {
196  wxString ret = aString;
197  ret.Replace( wxT( "\\" ), wxT( "/" ) );
198  return ret;
199  }
200 
201  wxString fromFileFormat( const wxString& aString ) const
202  {
203  wxString ret = aString;
204 #ifdef __WINDOWS__
205  ret.Replace( wxT( "/" ), wxT( "\\" ) );
206 #endif
207  return ret;
208  }
209 };
210 
214 template<typename EnumType>
215 class PARAM_ENUM : public PARAM_BASE
216 {
217 public:
218  PARAM_ENUM( const std::string& aJsonPath, EnumType* aPtr, EnumType aDefault,
219  EnumType aMin, EnumType aMax, bool aReadOnly = false ) :
220  PARAM_BASE( aJsonPath, aReadOnly ),
221  m_ptr( aPtr ),
222  m_min( aMin ),
223  m_max( aMax ),
224  m_default( aDefault )
225  {
226  }
227 
228  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
229  {
230  if( m_readOnly )
231  return;
232 
233  if( OPT<int> val = aSettings->Get<int>( m_path ) )
234  {
235  if( *val >= static_cast<int>( m_min ) && *val <= static_cast<int>( m_max ) )
236  *m_ptr = static_cast<EnumType>( *val );
237  else if( aResetIfMissing )
238  *m_ptr = m_default;
239 
240  }
241  else if( aResetIfMissing )
242  *m_ptr = m_default;
243  }
244 
245  void Store( JSON_SETTINGS* aSettings ) const override
246  {
247  aSettings->Set<int>( m_path, static_cast<int>( *m_ptr ) );
248  }
249 
250  EnumType GetDefault() const
251  {
252  return m_default;
253  }
254 
255  void SetDefault() override
256  {
257  *m_ptr = m_default;
258  }
259 
260  bool MatchesFile( JSON_SETTINGS* aSettings ) const override
261  {
262  if( OPT<int> val = aSettings->Get<int>( m_path ) )
263  return *val == static_cast<int>( *m_ptr );
264 
265  return false;
266  }
267 
268 private:
269  EnumType* m_ptr;
270  EnumType m_min;
271  EnumType m_max;
272  EnumType m_default;
273 };
274 
279 template<typename ValueType>
280 class PARAM_LAMBDA : public PARAM_BASE
281 {
282 public:
283  PARAM_LAMBDA( const std::string& aJsonPath, std::function<ValueType()> aGetter,
284  std::function<void( ValueType )> aSetter, ValueType aDefault,
285  bool aReadOnly = false ) :
286  PARAM_BASE( aJsonPath, aReadOnly ),
287  m_default( aDefault ),
288  m_getter( aGetter ),
289  m_setter( aSetter )
290  { }
291 
292  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
293 
294  void Store( JSON_SETTINGS* aSettings ) const override
295  {
296  try
297  {
298  aSettings->Set<ValueType>( m_path, m_getter() );
299  }
300  catch( ... )
301  {
302  }
303  }
304 
305  ValueType GetDefault() const
306  {
307  return m_default;
308  }
309 
310  void SetDefault() override
311  {
312  m_setter( m_default );
313  }
314 
315  bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
316 
317 private:
318  ValueType m_default;
319 
320  std::function<ValueType()> m_getter;
321 
322  std::function<void( ValueType )> m_setter;
323 };
324 
325 
332 template<typename ValueType>
334 {
335 public:
336  PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
337  double aScale = 1.0, bool aReadOnly = false ) :
338  PARAM_BASE( aJsonPath, aReadOnly ),
339  m_ptr( aPtr ),
340  m_default( aDefault ),
341  m_min(),
342  m_max(),
343  m_use_minmax( false ),
344  m_scale( aScale )
345  { }
346 
347  PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
348  ValueType aMin, ValueType aMax, double aScale = 1.0, bool aReadOnly = false ) :
349  PARAM_BASE( aJsonPath, aReadOnly ),
350  m_ptr( aPtr ),
351  m_default( aDefault ),
352  m_min( aMin ),
353  m_max( aMax ),
354  m_use_minmax( true ),
355  m_scale( aScale )
356  { }
357 
358  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
359  {
360  if( m_readOnly )
361  return;
362 
363  double dval = m_default * m_scale;
364 
365  if( OPT<double> optval = aSettings->Get<double>( m_path ) )
366  dval = *optval;
367  else if( !aResetIfMissing )
368  return;
369 
370  ValueType val = KiROUND<ValueType>( dval / m_scale );
371 
372  if( m_use_minmax )
373  {
374  if( val > m_max || val < m_min )
375  val = m_default;
376  }
377 
378  *m_ptr = val;
379  }
380 
381  void Store( JSON_SETTINGS* aSettings) const override
382  {
383  aSettings->Set<double>( m_path, *m_ptr * m_scale );
384  }
385 
386  ValueType GetDefault() const
387  {
388  return m_default;
389  }
390 
391  virtual void SetDefault() override
392  {
393  *m_ptr = m_default;
394  }
395 
396  bool MatchesFile( JSON_SETTINGS* aSettings ) const override
397  {
398  if( OPT<double> optval = aSettings->Get<double>( m_path ) )
399  return *optval == ( *m_ptr * m_scale );
400 
401  return false;
402  }
403 
404 private:
405  ValueType* m_ptr;
406  ValueType m_default;
407  ValueType m_min;
408  ValueType m_max;
410  double m_scale;
411 };
412 
413 template<typename Type>
414 class PARAM_LIST : public PARAM_BASE
415 {
416 public:
417  PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
418  std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
419  PARAM_BASE( aJsonPath, aReadOnly ),
420  m_ptr( aPtr ),
421  m_default( aDefault )
422  { }
423 
424  PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
425  std::vector<Type> aDefault, bool aReadOnly = false ) :
426  PARAM_BASE( aJsonPath, aReadOnly ),
427  m_ptr( aPtr ),
428  m_default( aDefault )
429  { }
430 
431  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
432 
433  void Store( JSON_SETTINGS* aSettings) const override;
434 
435  void SetDefault() override
436  {
437  *m_ptr = m_default;
438  }
439 
440  bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
441 
442 protected:
443  std::vector<Type>* m_ptr;
444 
445  std::vector<Type> m_default;
446 };
447 
452 class PARAM_PATH_LIST : public PARAM_LIST<wxString>
453 {
454 public:
455  PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
456  std::initializer_list<wxString> aDefault, bool aReadOnly = false ) :
457  PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
458  { }
459 
460  PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
461  std::vector<wxString> aDefault, bool aReadOnly = false ) :
462  PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
463  { }
464 
465  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
466  {
467  if( m_readOnly )
468  return;
469 
470  PARAM_LIST::Load( aSettings, aResetIfMissing );
471 
472  for( size_t i = 0; i < m_ptr->size(); i++ )
473  ( *m_ptr )[i] = fromFileFormat( ( *m_ptr )[i] );
474  }
475 
476  void Store( JSON_SETTINGS* aSettings) const override;
477 
478  bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
479 
480 private:
481  wxString toFileFormat( const wxString& aString ) const
482  {
483  wxString ret = aString;
484  ret.Replace( wxT( "\\" ), wxT( "/" ) );
485  return ret;
486  }
487 
488  wxString fromFileFormat( const wxString& aString ) const
489  {
490  wxString ret = aString;
491 #ifdef __WINDOWS__
492  ret.Replace( wxT( "/" ), wxT( "\\" ) );
493 #endif
494  return ret;
495  }
496 };
497 
510 template<typename Value>
511 class PARAM_MAP : public PARAM_BASE
512 {
513 public:
514  PARAM_MAP( const std::string& aJsonPath, std::map<std::string, Value>* aPtr,
515  std::initializer_list<std::pair<const std::string, Value>> aDefault,
516  bool aReadOnly = false ) :
517  PARAM_BASE( aJsonPath, aReadOnly ),
518  m_ptr( aPtr ),
519  m_default( aDefault )
520  { }
521 
522  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
523 
524  void Store( JSON_SETTINGS* aSettings) const override;
525 
526  virtual void SetDefault() override
527  {
528  *m_ptr = m_default;
529  }
530 
531  bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
532 
533 private:
534  std::map<std::string, Value>* m_ptr;
535 
536  std::map<std::string, Value> m_default;
537 };
538 
539 
544 {
545 public:
546  PARAM_WXSTRING_MAP( const std::string& aJsonPath, std::map<wxString, wxString>* aPtr,
547  std::initializer_list<std::pair<const wxString, wxString>> aDefault,
548  bool aReadOnly = false ) :
549  PARAM_BASE( aJsonPath, aReadOnly ),
550  m_ptr( aPtr ),
551  m_default( aDefault )
552  { }
553 
554  void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
555 
556  void Store( JSON_SETTINGS* aSettings) const override;
557 
558  virtual void SetDefault() override
559  {
560  *m_ptr = m_default;
561  }
562 
563  bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
564 
565 private:
566  std::map<wxString, wxString>* m_ptr;
567 
568  std::map<wxString, wxString> m_default;
569 };
570 
571 #endif
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.cpp:172
ValueType m_min
Definition: parameters.h:150
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:170
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
ValueType m_default
Definition: parameters.h:406
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::vector< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:460
virtual void SetDefault() override
Definition: parameters.h:391
virtual void SetDefault() override
Definition: parameters.h:558
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:280
std::map< std::string, Value > m_default
Definition: parameters.h:536
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:381
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:268
ValueType m_max
Definition: parameters.h:151
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:336
EnumType GetDefault() const
Definition: parameters.h:250
std::string m_path
the string used to store the param in json files
Definition: parameters.h:74
Represents a map of <std::string, Value>.
Definition: parameters.h:511
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:185
void SetDefault() override
Definition: parameters.h:435
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:152
std::map< wxString, wxString > * m_ptr
Definition: parameters.h:566
double m_scale
Definition: parameters.h:410
EnumType m_default
Definition: parameters.h:272
Definition: bitmap.cpp:64
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:193
bool m_use_minmax
Definition: parameters.h:152
Stores an enum as an integer.
Definition: parameters.h:215
std::map< wxString, wxString > m_default
Definition: parameters.h:568
EnumType m_max
Definition: parameters.h:271
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:180
std::function< ValueType()> m_getter
Definition: parameters.h:320
PARAM_LAMBDA(const std::string &aJsonPath, std::function< ValueType()> aGetter, std::function< void(ValueType)> aSetter, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:283
virtual void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const =0
Loads the value of this parameter from JSON to the underlying storage.
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:54
std::function< void(ValueType)> m_setter
Definition: parameters.h:322
PARAM_PATH(const std::string &aJsonPath, wxString *aPtr, const wxString &aDefault, bool aReadOnly=false)
Definition: parameters.h:165
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::initializer_list< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:455
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:254
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:396
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.cpp:31
Stores a path as a string with directory separators normalized to unix-style.
Definition: parameters.h:162
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:85
void SetDefault() override
Definition: parameters.h:136
bool m_use_minmax
Definition: parameters.h:409
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:465
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:141
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:488
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:141
void SetDefault() override
Definition: parameters.h:255
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.cpp:80
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:126
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:333
PARAM_ENUM(const std::string &aJsonPath, EnumType *aPtr, EnumType aDefault, EnumType aMin, EnumType aMax, bool aReadOnly=false)
Definition: parameters.h:218
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:260
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.cpp:232
virtual ~PARAM_BASE()=default
virtual void SetDefault() override
Definition: parameters.h:526
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:481
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:294
virtual void Store(JSON_SETTINGS *aSettings) const =0
Stores the value of this parameter to the given JSON_SETTINGS object.
std::vector< Type > * m_ptr
Definition: parameters.h:443
PARAM_MAP(const std::string &aJsonPath, std::map< std::string, Value > *aPtr, std::initializer_list< std::pair< const std::string, Value >> aDefault, bool aReadOnly=false)
Definition: parameters.h:514
ValueType * m_ptr
Definition: parameters.h:155
ValueType m_default
Definition: parameters.h:156
PARAM_BASE(std::string aJsonPath, bool aReadOnly)
Definition: parameters.h:35
ValueType m_default
Definition: parameters.h:318
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:347
EnumType m_min
Definition: parameters.h:270
virtual void SetDefault()=0
std::map< std::string, Value > * m_ptr
Definition: parameters.h:534
A helper for <wxString, wxString> maps.
Definition: parameters.h:543
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:205
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:228
OPT< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
ValueType m_min
Definition: parameters.h:407
bool m_readOnly
! True if the parameter pointer should never be overwritten
Definition: parameters.h:77
ValueType GetDefault() const
Definition: parameters.h:305
virtual bool MatchesFile(JSON_SETTINGS *aSettings) const =0
Checks whether the parameter in memory matches the one in a given JSON file.
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::vector< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:424
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:358
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:201
boost::optional< T > OPT
Definition: optional.h:7
PARAM_WXSTRING_MAP(const std::string &aJsonPath, std::map< wxString, wxString > *aPtr, std::initializer_list< std::pair< const wxString, wxString >> aDefault, bool aReadOnly=false)
Definition: parameters.h:546
ValueType m_max
Definition: parameters.h:408
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::initializer_list< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:417
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:245
ValueType GetDefault() const
Definition: parameters.h:386
Represents a list of strings holding directory paths.
Definition: parameters.h:452
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, bool aReadOnly=false)
Definition: parameters.h:95
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:115
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:103
EnumType * m_ptr
Definition: parameters.h:269
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:194
ValueType * m_ptr
Definition: parameters.h:405
void SetDefault() override
Definition: parameters.h:310
const std::string & GetJsonPath() const
Definition: parameters.h:68
void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition: parameters.h:105
std::vector< Type > m_default
Definition: parameters.h:445
ValueType GetDefault() const
Definition: parameters.h:131