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 <[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 <string>
25#include <utility>
26#include <math/util.h>
27
28#include <optional>
30
31
33{
34public:
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
70protected:
74 std::string m_path;
75
78};
79
80
81template<typename ValueType>
82class PARAM : public PARAM_BASE
83{
84public:
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( std::optional<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( std::optional<ValueType> optval = aSettings->Get<ValueType>( m_path ) )
144 return *optval == *m_ptr;
145
146 return false;
147 }
148
149private:
150 ValueType m_min;
151 ValueType m_max;
153
154protected:
155 ValueType* m_ptr;
156 ValueType m_default;
157};
158
162class PARAM_PATH : public PARAM<wxString>
163{
164public:
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
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( std::optional<wxString> optval = aSettings->Get<wxString>( m_path ) )
188 return fromFileFormat( *optval ) == *m_ptr;
189
190 return false;
191 }
192
193private:
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
214template<typename EnumType>
215class PARAM_ENUM : public PARAM_BASE
216{
217public:
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( std::optional<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( std::optional<int> val = aSettings->Get<int>( m_path ) )
263 return *val == static_cast<int>( *m_ptr );
264
265 return false;
266 }
267
268private:
269 EnumType* m_ptr;
270 EnumType m_min;
271 EnumType m_max;
272 EnumType m_default;
273};
274
279template<typename ValueType>
281{
282public:
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 {
313 }
314
315 bool MatchesFile( JSON_SETTINGS* aSettings ) const override;
316
317private:
318 ValueType m_default;
319
320 std::function<ValueType()> m_getter;
321
322 std::function<void( ValueType )> m_setter;
323};
324
325
332template<typename ValueType>
334{
335public:
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( std::optional<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( std::optional<double> optval = aSettings->Get<double>( m_path ) )
399 return *optval == ( *m_ptr * m_scale );
400
401 return false;
402 }
403
404private:
405 ValueType* m_ptr;
406 ValueType m_default;
407 ValueType m_min;
408 ValueType m_max;
410 double m_scale;
411};
412
413template<typename Type>
414class PARAM_LIST : public PARAM_BASE
415{
416public:
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
442protected:
443 std::vector<Type>* m_ptr;
444
445 std::vector<Type> m_default;
446};
447
452class PARAM_PATH_LIST : public PARAM_LIST<wxString>
453{
454public:
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
480private:
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
510template<typename Value>
511class PARAM_MAP : public PARAM_BASE
512{
513public:
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
533private:
534 std::map<std::string, Value>* m_ptr;
535
536 std::map<std::string, Value> m_default;
537};
538
539
544{
545public:
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
565private:
566 std::map<wxString, wxString>* m_ptr;
567
568 std::map<wxString, wxString> m_default;
569};
570
571#endif
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...
std::optional< ValueType > Get(const std::string &aPath) const
Fetches a value from within the JSON document.
PARAM_BASE(std::string aJsonPath, bool aReadOnly)
Definition: parameters.h:35
bool m_readOnly
! True if the parameter pointer should never be overwritten
Definition: parameters.h:77
const std::string & GetJsonPath() const
Definition: parameters.h:68
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:74
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:216
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
EnumType m_default
Definition: parameters.h:272
void SetDefault() override
Definition: parameters.h:255
EnumType GetDefault() const
Definition: parameters.h:250
EnumType * m_ptr
Definition: parameters.h:269
PARAM_ENUM(const std::string &aJsonPath, EnumType *aPtr, EnumType aDefault, EnumType aMin, EnumType aMax, bool aReadOnly=false)
Definition: parameters.h:218
EnumType m_min
Definition: parameters.h:270
EnumType m_max
Definition: parameters.h:271
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 Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:245
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:281
std::function< void(ValueType)> m_setter
Definition: parameters.h:322
std::function< ValueType()> m_getter
Definition: parameters.h:320
ValueType m_default
Definition: parameters.h:318
void SetDefault() override
Definition: parameters.h:310
ValueType GetDefault() const
Definition: parameters.h:305
PARAM_LAMBDA(const std::string &aJsonPath, std::function< ValueType()> aGetter, std::function< void(ValueType)> aSetter, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:283
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
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:294
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
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:417
std::vector< Type > * m_ptr
Definition: parameters.h:443
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:445
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::vector< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:424
void SetDefault() override
Definition: parameters.h:435
Represents a map of <std::string, Value>.
Definition: parameters.h:512
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
virtual void SetDefault() override
Definition: parameters.h:526
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
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:193
std::map< std::string, Value > m_default
Definition: parameters.h:536
std::map< std::string, Value > * m_ptr
Definition: parameters.h:534
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
Represents a list of strings holding directory paths.
Definition: parameters.h:453
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:481
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
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.cpp:152
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.cpp:141
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::initializer_list< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:455
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::vector< wxString > aDefault, bool aReadOnly=false)
Definition: parameters.h:460
Stores a path as a string with directory separators normalized to unix-style.
Definition: parameters.h:163
PARAM_PATH(const std::string &aJsonPath, wxString *aPtr, const wxString &aDefault, bool aReadOnly=false)
Definition: parameters.h:165
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:201
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:180
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:194
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 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
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:334
ValueType GetDefault() const
Definition: parameters.h:386
bool m_use_minmax
Definition: parameters.h:409
ValueType m_default
Definition: parameters.h:406
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:381
ValueType m_max
Definition: parameters.h:408
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
double m_scale
Definition: parameters.h:410
ValueType * m_ptr
Definition: parameters.h:405
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
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:336
virtual void SetDefault() override
Definition: parameters.h:391
ValueType m_min
Definition: parameters.h:407
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
A helper for <wxString, wxString> maps.
Definition: parameters.h:544
virtual void SetDefault() override
Definition: parameters.h:558
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.cpp:268
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
std::map< wxString, wxString > * m_ptr
Definition: parameters.h:566
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
std::map< wxString, wxString > m_default
Definition: parameters.h:568
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
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:136
ValueType * m_ptr
Definition: parameters.h:155
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, bool aReadOnly=false)
Definition: parameters.h:95
ValueType m_default
Definition: parameters.h:156
bool m_use_minmax
Definition: parameters.h:152
ValueType GetDefault() const
Definition: parameters.h:131
ValueType m_min
Definition: parameters.h:150
ValueType m_max
Definition: parameters.h:151
PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:85
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:126
Definition: bitmap.cpp:64