KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
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 <set>
25#include <string>
26#include <utility>
27#include <math/util.h>
28
29#include <optional>
31
32
34{
35public:
36 PARAM_BASE( std::string aJsonPath, bool aReadOnly ) :
37 m_path( std::move( aJsonPath ) ),
38 m_readOnly( aReadOnly )
39 {}
40
41 virtual ~PARAM_BASE() = default;
42
48 virtual void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const = 0;
49
54 virtual void Store( JSON_SETTINGS* aSettings ) const = 0;
55
56 virtual void SetDefault() = 0;
57
63 virtual bool MatchesFile( JSON_SETTINGS* aSettings ) const = 0;
64
69 const std::string& GetJsonPath() const { return m_path; }
70
71protected:
75 std::string m_path;
76
79};
80
81
82template<typename ValueType>
83class PARAM : public PARAM_BASE
84{
85public:
86 PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
87 bool aReadOnly = false ) :
88 PARAM_BASE( aJsonPath, aReadOnly ),
89 m_min(),
90 m_max(),
91 m_use_minmax( false ),
92 m_ptr( aPtr ),
93 m_default( aDefault )
94 { }
95
96 PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, ValueType aMin,
97 ValueType aMax, bool aReadOnly = false ) :
98 PARAM_BASE( aJsonPath, aReadOnly ),
99 m_min( aMin ),
100 m_max( aMax ),
101 m_use_minmax( true ),
102 m_ptr( aPtr ),
103 m_default( aDefault )
104 { }
105
106 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
107 {
108 if( m_readOnly )
109 return;
110
111 if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
112 {
113 ValueType val = *optval;
114
115 if( m_use_minmax )
116 {
117 if( m_max < val || val < m_min )
118 val = m_default;
119 }
120
121 *m_ptr = val;
122 }
123 else if( aResetIfMissing )
124 *m_ptr = m_default;
125 }
126
127 void Store( JSON_SETTINGS* aSettings ) const override
128 {
129 aSettings->Set<ValueType>( m_path, *m_ptr );
130 }
131
132 ValueType GetDefault() const
133 {
134 return m_default;
135 }
136
137 void SetDefault() override
138 {
139 *m_ptr = m_default;
140 }
141
142 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
143 {
144 if( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
145 return *optval == *m_ptr;
146
147 return false;
148 }
149
150private:
151 ValueType m_min;
152 ValueType m_max;
154
155protected:
156 ValueType* m_ptr;
157 ValueType m_default;
158};
159
163class PARAM_PATH : public PARAM<wxString>
164{
165public:
166 PARAM_PATH( const std::string& aJsonPath, wxString* aPtr, const wxString& aDefault,
167 bool aReadOnly = false ) :
168 PARAM( aJsonPath, aPtr, aDefault, aReadOnly )
169 { }
170
171 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
172 {
173 if( m_readOnly )
174 return;
175
176 PARAM::Load( aSettings, aResetIfMissing );
177
179 }
180
181 void Store( JSON_SETTINGS* aSettings ) const override
182 {
183 aSettings->Set<wxString>( m_path, toFileFormat( *m_ptr ) );
184 }
185
186 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
187 {
188 if( std::optional<wxString> optval = aSettings->Get<wxString>( m_path ) )
189 return fromFileFormat( *optval ) == *m_ptr;
190
191 return false;
192 }
193
194private:
195 wxString toFileFormat( const wxString& aString ) const
196 {
197 wxString ret = aString;
198 ret.Replace( wxT( "\\" ), wxT( "/" ) );
199 return ret;
200 }
201
202 wxString fromFileFormat( const wxString& aString ) const
203 {
204 wxString ret = aString;
205#ifdef __WINDOWS__
206 ret.Replace( wxT( "/" ), wxT( "\\" ) );
207#endif
208 return ret;
209 }
210};
211
215template<typename EnumType>
216class PARAM_ENUM : public PARAM_BASE
217{
218public:
219 PARAM_ENUM( const std::string& aJsonPath, EnumType* aPtr, EnumType aDefault,
220 EnumType aMin, EnumType aMax, bool aReadOnly = false ) :
221 PARAM_BASE( aJsonPath, aReadOnly ),
222 m_ptr( aPtr ),
223 m_min( aMin ),
224 m_max( aMax ),
225 m_default( aDefault )
226 {
227 }
228
229 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
230 {
231 if( m_readOnly )
232 return;
233
234 if( std::optional<int> val = aSettings->Get<int>( m_path ) )
235 {
236 if( *val >= static_cast<int>( m_min ) && *val <= static_cast<int>( m_max ) )
237 *m_ptr = static_cast<EnumType>( *val );
238 else if( aResetIfMissing )
239 *m_ptr = m_default;
240
241 }
242 else if( aResetIfMissing )
243 *m_ptr = m_default;
244 }
245
246 void Store( JSON_SETTINGS* aSettings ) const override
247 {
248 aSettings->Set<int>( m_path, static_cast<int>( *m_ptr ) );
249 }
250
251 EnumType GetDefault() const
252 {
253 return m_default;
254 }
255
256 void SetDefault() override
257 {
258 *m_ptr = m_default;
259 }
260
261 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
262 {
263 if( std::optional<int> val = aSettings->Get<int>( m_path ) )
264 return *val == static_cast<int>( *m_ptr );
265
266 return false;
267 }
268
269private:
270 EnumType* m_ptr;
271 EnumType m_min;
272 EnumType m_max;
273 EnumType m_default;
274};
275
280template<typename ValueType>
282{
283public:
284 PARAM_LAMBDA( const std::string& aJsonPath, std::function<ValueType()> aGetter,
285 std::function<void( ValueType )> aSetter, ValueType aDefault,
286 bool aReadOnly = false ) :
287 PARAM_BASE( aJsonPath, aReadOnly ),
288 m_default( aDefault ),
289 m_getter( aGetter ),
290 m_setter( aSetter )
291 { }
292
293 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
294
295 void Store( JSON_SETTINGS* aSettings ) const override
296 {
297 try
298 {
299 aSettings->Set<ValueType>( m_path, m_getter() );
300 }
301 catch( ... )
302 {
303 }
304 }
305
306 ValueType GetDefault() const
307 {
308 return m_default;
309 }
310
311 void SetDefault() override
312 {
314 }
315
316 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
317
318private:
319 ValueType m_default;
320
321 std::function<ValueType()> m_getter;
322
323 std::function<void( ValueType )> m_setter;
324};
325
326
333template<typename ValueType>
335{
336public:
337 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
338 double aScale = 1.0, bool aReadOnly = false ) :
339 PARAM_BASE( aJsonPath, aReadOnly ),
340 m_ptr( aPtr ),
341 m_default( aDefault ),
342 m_min(),
343 m_max(),
344 m_use_minmax( false ),
345 m_scale( aScale )
346 { }
347
348 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
349 ValueType aMin, ValueType aMax, double aScale = 1.0, bool aReadOnly = false ) :
350 PARAM_BASE( aJsonPath, aReadOnly ),
351 m_ptr( aPtr ),
352 m_default( aDefault ),
353 m_min( aMin ),
354 m_max( aMax ),
355 m_use_minmax( true ),
356 m_scale( aScale )
357 { }
358
359 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
360 {
361 if( m_readOnly )
362 return;
363
364 double dval = m_default * m_scale;
365
366 if( std::optional<double> optval = aSettings->Get<double>( m_path ) )
367 dval = *optval;
368 else if( !aResetIfMissing )
369 return;
370
371 ValueType val = KiROUND<ValueType>( dval / m_scale );
372
373 if( m_use_minmax )
374 {
375 if( val > m_max || val < m_min )
376 val = m_default;
377 }
378
379 *m_ptr = val;
380 }
381
382 void Store( JSON_SETTINGS* aSettings) const override
383 {
384 aSettings->Set<double>( m_path, *m_ptr * m_scale );
385 }
386
387 ValueType GetDefault() const
388 {
389 return m_default;
390 }
391
392 virtual void SetDefault() override
393 {
394 *m_ptr = m_default;
395 }
396
397 bool MatchesFile( JSON_SETTINGS* aSettings ) const override
398 {
399 if( std::optional<double> optval = aSettings->Get<double>( m_path ) )
400 return *optval == ( *m_ptr * m_scale );
401
402 return false;
403 }
404
405private:
406 ValueType* m_ptr;
407 ValueType m_default;
408 ValueType m_min;
409 ValueType m_max;
411 double m_scale;
412};
413
414template<typename Type>
415class PARAM_LIST : public PARAM_BASE
416{
417public:
418 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
419 std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
420 PARAM_BASE( aJsonPath, aReadOnly ),
421 m_ptr( aPtr ),
422 m_default( aDefault )
423 { }
424
425 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
426 std::vector<Type> aDefault, bool aReadOnly = false ) :
427 PARAM_BASE( aJsonPath, aReadOnly ),
428 m_ptr( aPtr ),
429 m_default( aDefault )
430 { }
431
432 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
433
434 void Store( JSON_SETTINGS* aSettings) const override;
435
436 void SetDefault() override
437 {
438 *m_ptr = m_default;
439 }
440
441 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
442
443protected:
444 std::vector<Type>* m_ptr;
445
446 std::vector<Type> m_default;
447};
448
449template<typename Type>
450class PARAM_SET : public PARAM_BASE
451{
452public:
453 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
454 std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
455 PARAM_BASE( aJsonPath, aReadOnly ),
456 m_ptr( aPtr ),
457 m_default( aDefault )
458 { }
459
460 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
461 std::set<Type> aDefault, bool aReadOnly = false ) :
462 PARAM_BASE( aJsonPath, aReadOnly ),
463 m_ptr( aPtr ),
464 m_default( aDefault )
465 { }
466
467 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
468
469 void Store( JSON_SETTINGS* aSettings) const override;
470
471 void SetDefault() override
472 {
473 *m_ptr = m_default;
474 }
475
476 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
477
478protected:
479 std::set<Type>* m_ptr;
480
481 std::set<Type> m_default;
482};
483
488class PARAM_PATH_LIST : public PARAM_LIST<wxString>
489{
490public:
491 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
492 std::initializer_list<wxString> aDefault, bool aReadOnly = false ) :
493 PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
494 { }
495
496 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
497 std::vector<wxString> aDefault, bool aReadOnly = false ) :
498 PARAM_LIST( aJsonPath, aPtr, aDefault, aReadOnly )
499 { }
500
501 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override
502 {
503 if( m_readOnly )
504 return;
505
506 PARAM_LIST::Load( aSettings, aResetIfMissing );
507
508 for( size_t i = 0; i < m_ptr->size(); i++ )
509 ( *m_ptr )[i] = fromFileFormat( ( *m_ptr )[i] );
510 }
511
512 void Store( JSON_SETTINGS* aSettings) const override;
513
514 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
515
516private:
517 wxString toFileFormat( const wxString& aString ) const
518 {
519 wxString ret = aString;
520 ret.Replace( wxT( "\\" ), wxT( "/" ) );
521 return ret;
522 }
523
524 wxString fromFileFormat( const wxString& aString ) const
525 {
526 wxString ret = aString;
527#ifdef __WINDOWS__
528 ret.Replace( wxT( "/" ), wxT( "\\" ) );
529#endif
530 return ret;
531 }
532};
533
546template<typename Value>
547class PARAM_MAP : public PARAM_BASE
548{
549public:
550 PARAM_MAP( const std::string& aJsonPath, std::map<std::string, Value>* aPtr,
551 std::initializer_list<std::pair<const std::string, Value>> aDefault,
552 bool aReadOnly = false ) :
553 PARAM_BASE( aJsonPath, aReadOnly ),
554 m_ptr( aPtr ),
555 m_default( aDefault )
556 { }
557
558 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
559
560 void Store( JSON_SETTINGS* aSettings) const override;
561
562 virtual void SetDefault() override
563 {
564 *m_ptr = m_default;
565 }
566
567 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
568
569private:
570 std::map<std::string, Value>* m_ptr;
571
572 std::map<std::string, Value> m_default;
573};
574
575
580{
581public:
582 PARAM_WXSTRING_MAP( const std::string& aJsonPath, std::map<wxString, wxString>* aPtr,
583 std::initializer_list<std::pair<const wxString, wxString>> aDefault,
584 bool aReadOnly = false ) :
585 PARAM_BASE( aJsonPath, aReadOnly ),
586 m_ptr( aPtr ),
587 m_default( aDefault )
588 { }
589
590 void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override;
591
592 void Store( JSON_SETTINGS* aSettings) const override;
593
594 virtual void SetDefault() override
595 {
596 *m_ptr = m_default;
597 }
598
599 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
600
601private:
602 std::map<wxString, wxString>* m_ptr;
603
604 std::map<wxString, wxString> m_default;
605};
606
607#endif
std::optional< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
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...
PARAM_BASE(std::string aJsonPath, bool aReadOnly)
Definition: parameters.h:36
bool m_readOnly
! True if the parameter pointer should never be overwritten
Definition: parameters.h:78
const std::string & GetJsonPath() const
Definition: parameters.h:69
virtual void SetDefault()=0
virtual void Load(JSON_SETTINGS *aSettings, bool aResetIfMissing=true) const =0
Loads the value of this parameter from JSON to the underlying storage.
virtual void Store(JSON_SETTINGS *aSettings) const =0
Stores the value of this parameter to the given JSON_SETTINGS object.
virtual ~PARAM_BASE()=default
std::string m_path
the string used to store the param in json files
Definition: parameters.h:75
virtual bool MatchesFile(JSON_SETTINGS *aSettings) const =0
Checks whether the parameter in memory matches the one in a given JSON file.
Stores an enum as an integer.
Definition: parameters.h:217
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:229
EnumType m_default
Definition: parameters.h:273
void SetDefault() override
Definition: parameters.h:256
EnumType GetDefault() const
Definition: parameters.h:251
EnumType * m_ptr
Definition: parameters.h:270
PARAM_ENUM(const std::string &aJsonPath, EnumType *aPtr, EnumType aDefault, EnumType aMin, EnumType aMax, bool aReadOnly=false)
Definition: parameters.h:219
EnumType m_min
Definition: parameters.h:271
EnumType m_max
Definition: parameters.h:272
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:261
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:246
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:282
std::function< void(ValueType)> m_setter
Definition: parameters.h:323
std::function< ValueType()> m_getter
Definition: parameters.h:321
ValueType m_default
Definition: parameters.h:319
void SetDefault() override
Definition: parameters.h:311
ValueType GetDefault() const
Definition: parameters.h:306
PARAM_LAMBDA(const std::string &aJsonPath, std::function< ValueType()> aGetter, std::function< void(ValueType)> aSetter, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:284
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:32
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:295
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:55
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
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::initializer_list< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:418
std::vector< Type > * m_ptr
Definition: parameters.h:444
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
std::vector< Type > m_default
Definition: parameters.h:446
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::vector< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:425
void SetDefault() override
Definition: parameters.h:436
Represents a map of <std::string, Value>.
Definition: parameters.h:548
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:275
virtual void SetDefault() override
Definition: parameters.h:562
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:550
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:263
std::map< std::string, Value > m_default
Definition: parameters.h:572
std::map< std::string, Value > * m_ptr
Definition: parameters.h:570
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:242
Represents a list of strings holding directory paths.
Definition: parameters.h:489
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:517
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:501
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:524
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:222
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:211
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::initializer_list< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:491
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::vector< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:496
Stores a path as a string with directory separators normalized to unix-style.
Definition: parameters.h:164
PARAM_PATH(const std::string &aJsonPath, wxString *aPtr, const wxString &aDefault, bool aReadOnly=false)
Definition: parameters.h:166
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:202
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:181
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:195
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:186
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:171
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:335
ValueType GetDefault() const
Definition: parameters.h:387
bool m_use_minmax
Definition: parameters.h:410
ValueType m_default
Definition: parameters.h:407
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:382
ValueType m_max
Definition: parameters.h:409
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:397
double m_scale
Definition: parameters.h:411
ValueType * m_ptr
Definition: parameters.h:406
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:359
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:337
virtual void SetDefault() override
Definition: parameters.h:392
ValueType m_min
Definition: parameters.h:408
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:348
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:177
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::initializer_list< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:453
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::set< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:460
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:154
std::set< Type > * m_ptr
Definition: parameters.h:479
void SetDefault() override
Definition: parameters.h:471
std::set< Type > m_default
Definition: parameters.h:481
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:189
A helper for <wxString, wxString> maps.
Definition: parameters.h:580
virtual void SetDefault() override
Definition: parameters.h:594
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:324
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.cpp:338
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:302
std::map< wxString, wxString > * m_ptr
Definition: parameters.h:602
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:582
std::map< wxString, wxString > m_default
Definition: parameters.h:604
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:106
bool MatchesFile(JSON_SETTINGS *aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition: parameters.h:142
void SetDefault() override
Definition: parameters.h:137
ValueType * m_ptr
Definition: parameters.h:156
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, bool aReadOnly=false)
Definition: parameters.h:96
ValueType m_default
Definition: parameters.h:157
bool m_use_minmax
Definition: parameters.h:153
ValueType GetDefault() const
Definition: parameters.h:132
ValueType m_min
Definition: parameters.h:151
ValueType m_max
Definition: parameters.h:152
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:86
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:127
STL namespace.