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 The 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>
30#include <gal/color4d.h>
33#include <kicommon.h>
34
36{
37public:
38 PARAM_BASE( std::string aJsonPath, bool aReadOnly ) :
39 m_path( std::move( aJsonPath ) ),
40 m_readOnly( aReadOnly ),
41 m_clearUnknownKeys( false )
42 {}
43
44 virtual ~PARAM_BASE() = default;
45
51 virtual void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const = 0;
52
57 virtual void Store( JSON_SETTINGS* aSettings ) const = 0;
58
59 virtual void SetDefault() = 0;
60
66 virtual bool MatchesFile( const JSON_SETTINGS& aSettings ) const = 0;
67
72 const std::string& GetJsonPath() const { return m_path; }
73
78 bool ClearUnknownKeys() const { return m_clearUnknownKeys; }
79
80 void SetClearUnknownKeys( bool aSet = true ) { m_clearUnknownKeys = aSet; }
81
82protected:
83 std::string m_path;
88};
89
90
91template<typename ValueType>
92class PARAM : public PARAM_BASE
93{
94public:
95 PARAM( const std::string& aJsonPath, ValueType* aPtr, const ValueType& aDefault,
96 bool aReadOnly = false ) :
97 PARAM_BASE( aJsonPath, aReadOnly ),
98 m_min(),
99 m_max(),
100 m_use_minmax( false ),
101 m_ptr( aPtr ),
102 m_default( aDefault )
103 { }
104
105 PARAM( const std::string& aJsonPath, ValueType* aPtr, const ValueType& aDefault,
106 const ValueType& aMin, const ValueType& aMax, bool aReadOnly = false ) :
107 PARAM_BASE( aJsonPath, aReadOnly ),
108 m_min( aMin ),
109 m_max( aMax ),
110 m_use_minmax( true ),
111 m_ptr( aPtr ),
112 m_default( aDefault )
113 { }
114
115 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
116 {
117 if( m_readOnly )
118 return;
119
120 if( std::optional<ValueType> optval = aSettings.Get<ValueType>( m_path ) )
121 {
122 ValueType val = *optval;
123
124 if( m_use_minmax )
125 {
126 if( m_max < val || val < m_min )
127 val = m_default;
128 }
129
130 *m_ptr = val;
131 }
132 else if( aResetIfMissing )
133 {
134 *m_ptr = m_default;
135 }
136 }
137
138 void Store( JSON_SETTINGS* aSettings ) const override
139 {
140 aSettings->Set<ValueType>( m_path, *m_ptr );
141 }
142
143 ValueType GetDefault() const
144 {
145 return m_default;
146 }
147
148 void SetDefault() override
149 {
150 *m_ptr = m_default;
151 }
152
153 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
154 {
155 if( std::optional<ValueType> optval = aSettings.Get<ValueType>( m_path ) )
156 return *optval == *m_ptr;
157
158 return false;
159 }
160
161private:
162 ValueType m_min;
163 ValueType m_max;
165
166protected:
167 ValueType* m_ptr;
168 ValueType m_default;
169};
170
174class KICOMMON_API PARAM_PATH : public PARAM<wxString>
175{
176public:
177 PARAM_PATH( const std::string& aJsonPath, wxString* aPtr, const wxString& aDefault,
178 bool aReadOnly = false ) :
179 PARAM( aJsonPath, aPtr, aDefault, aReadOnly )
180 { }
181
182 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
183 {
184 if( m_readOnly )
185 return;
186
187 PARAM::Load( aSettings, aResetIfMissing );
188
190 }
191
192 void Store( JSON_SETTINGS* aSettings ) const override
193 {
194 aSettings->Set<wxString>( m_path, toFileFormat( *m_ptr ) );
195 }
196
197 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
198 {
199 if( std::optional<wxString> optval = aSettings.Get<wxString>( m_path ) )
200 return fromFileFormat( *optval ) == *m_ptr;
201
202 return false;
203 }
204
205private:
206 wxString toFileFormat( const wxString& aString ) const
207 {
208 wxString ret = aString;
209 ret.Replace( wxT( "\\" ), wxT( "/" ) );
210 return ret;
211 }
212
213 wxString fromFileFormat( const wxString& aString ) const
214 {
215 wxString ret = aString;
216#ifdef __WINDOWS__
217 if( !ret.Contains( wxT( "://" ) ) )
218 ret.Replace( wxT( "/" ), wxT( "\\" ) );
219#endif
220 return ret;
221 }
222};
223
227template<typename EnumType>
228class PARAM_ENUM : public PARAM_BASE
229{
230public:
231 PARAM_ENUM( const std::string& aJsonPath, EnumType* aPtr, EnumType aDefault,
232 EnumType aMin, EnumType aMax, bool aReadOnly = false ) :
233 PARAM_BASE( aJsonPath, aReadOnly ),
234 m_ptr( aPtr ),
235 m_min( aMin ),
236 m_max( aMax ),
237 m_default( aDefault )
238 {
239 }
240
241 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
242 {
243 if( m_readOnly )
244 return;
245
246 if( std::optional<int> val = aSettings.Get<int>( m_path ) )
247 {
248 if( *val >= static_cast<int>( m_min ) && *val <= static_cast<int>( m_max ) )
249 *m_ptr = static_cast<EnumType>( *val );
250 else if( aResetIfMissing )
251 *m_ptr = m_default;
252
253 }
254 else if( aResetIfMissing )
255 {
256 *m_ptr = m_default;
257 }
258 }
259
260 void Store( JSON_SETTINGS* aSettings ) const override
261 {
262 aSettings->Set<int>( m_path, static_cast<int>( *m_ptr ) );
263 }
264
265 EnumType GetDefault() const
266 {
267 return m_default;
268 }
269
270 void SetDefault() override
271 {
272 *m_ptr = m_default;
273 }
274
275 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
276 {
277 if( std::optional<int> val = aSettings.Get<int>( m_path ) )
278 return *val == static_cast<int>( *m_ptr );
279
280 return false;
281 }
282
283private:
284 EnumType* m_ptr;
285 EnumType m_min;
286 EnumType m_max;
287 EnumType m_default;
288};
289
294template<typename ValueType>
296{
297public:
298 PARAM_LAMBDA( const std::string& aJsonPath, std::function<ValueType()> aGetter,
299 std::function<void( ValueType )> aSetter, ValueType aDefault,
300 bool aReadOnly = false ) :
301 PARAM_BASE( aJsonPath, aReadOnly ),
302 m_default( std::move( aDefault ) ),
303 m_getter( std::move( aGetter ) ),
304 m_setter( std::move( aSetter ) )
305 {
306 }
307
308 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
309 {
310 if( m_readOnly )
311 return;
312
313 if( std::is_same<ValueType, nlohmann::json>::value )
314 {
315 if( std::optional<nlohmann::json> optval = aSettings.GetJson( m_path ) )
316 m_setter( *optval );
317 else
319 }
320 else
321 {
322 if( std::optional<ValueType> optval = aSettings.Get<ValueType>( m_path ) )
323 m_setter( *optval );
324 else
326 }
327 }
328
329 void Store( JSON_SETTINGS* aSettings ) const override
330 {
331 try
332 {
333 aSettings->Set<ValueType>( m_path, m_getter() );
334 }
335 catch( ... )
336 {
337 }
338 }
339
340 ValueType GetDefault() const
341 {
342 return m_default;
343 }
344
345 void SetDefault() override
346 {
348 }
349
350 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
351 {
352 if( std::is_same<ValueType, nlohmann::json>::value )
353 {
354 if( std::optional<nlohmann::json> optval = aSettings.GetJson( m_path ) )
355 return *optval == m_getter();
356 }
357 else
358 {
359 if( std::optional<ValueType> optval = aSettings.Get<ValueType>( m_path ) )
360 return *optval == m_getter();
361 }
362
363 // Not in file
364 return false;
365 }
366
367private:
368 ValueType m_default;
369 std::function<ValueType()> m_getter;
370 std::function<void( ValueType )> m_setter;
371};
372
373#ifdef __WINDOWS__
374template class KICOMMON_API PARAM_LAMBDA<bool>;
375template class KICOMMON_API PARAM_LAMBDA<int>;
378#else
379extern template class APIVISIBLE PARAM_LAMBDA<bool>;
380extern template class APIVISIBLE PARAM_LAMBDA<int>;
381extern template class APIVISIBLE PARAM_LAMBDA<nlohmann::json>;
382extern template class APIVISIBLE PARAM_LAMBDA<std::string>;
383#endif
384
391template<typename ValueType>
393{
394public:
395 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
396 double aScale = 1.0, bool aReadOnly = false ) :
397 PARAM_BASE( aJsonPath, aReadOnly ),
398 m_ptr( aPtr ),
399 m_default( aDefault ),
400 m_min(),
401 m_max(),
402 m_use_minmax( false ),
403 m_scale( aScale ),
404 m_invScale( 1.0 / aScale )
405 { }
406
407 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
408 ValueType aMin, ValueType aMax, double aScale = 1.0, bool aReadOnly = false ) :
409 PARAM_BASE( aJsonPath, aReadOnly ),
410 m_ptr( aPtr ),
411 m_default( aDefault ),
412 m_min( aMin ),
413 m_max( aMax ),
414 m_use_minmax( true ),
415 m_scale( aScale ),
416 m_invScale( 1.0 / aScale )
417 { }
418
419 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
420 {
421 if( m_readOnly )
422 return;
423
424 double dval = m_default / m_invScale;
425
426 if( std::optional<double> optval = aSettings.Get<double>( m_path ) )
427 dval = *optval;
428 else if( !aResetIfMissing )
429 return;
430
431 ValueType val = KiROUND<double, ValueType>( dval * m_invScale );
432
433 if( m_use_minmax )
434 {
435 if( val > m_max || val < m_min )
436 val = m_default;
437 }
438
439 *m_ptr = val;
440 }
441
442 void Store( JSON_SETTINGS* aSettings) const override
443 {
444 aSettings->Set<double>( m_path, *m_ptr / m_invScale );
445 }
446
447 ValueType GetDefault() const
448 {
449 return m_default;
450 }
451
452 virtual void SetDefault() override
453 {
454 *m_ptr = m_default;
455 }
456
457 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
458 {
459 if( std::optional<double> optval = aSettings.Get<double>( m_path ) )
460 return *optval == ( *m_ptr / m_invScale );
461
462 return false;
463 }
464
465private:
466 ValueType* m_ptr;
467 ValueType m_default;
468 ValueType m_min;
469 ValueType m_max;
471 double m_scale;
473};
474
475template<typename Type>
476class PARAM_LIST : public PARAM_BASE
477{
478public:
479 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
480 std::initializer_list<Type> aDefault, bool aResetIfEmpty = false ) :
481 PARAM_BASE( aJsonPath, false ),
482 m_ptr( aPtr ),
483 m_default( aDefault ),
484 m_resetIfEmpty( aResetIfEmpty )
485 { }
486
487 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
488 std::vector<Type> aDefault, bool aResetIfEmpty = false ) :
489 PARAM_BASE( aJsonPath, false ),
490 m_ptr( aPtr ),
491 m_default( std::move( aDefault ) ),
492 m_resetIfEmpty( aResetIfEmpty )
493 { }
494
495 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
496 {
497 if( m_readOnly )
498 return;
499
500 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
501 {
502 std::vector<Type> val;
503
504 if( js->is_array() )
505 {
506 for( const auto& el : js->items() )
507 val.push_back( el.value().get<Type>() );
508 }
509
510 if( val.empty() && m_resetIfEmpty )
511 *m_ptr = m_default;
512 else
513 *m_ptr = val;
514 }
515 else if( aResetIfMissing )
516 {
517 *m_ptr = m_default;
518 }
519 }
520
521 void Store( JSON_SETTINGS* aSettings ) const override
522 {
523 nlohmann::json js = nlohmann::json::array();
524
525 for( const auto& el : *m_ptr )
526 js.push_back( el );
527
528 aSettings->Set<nlohmann::json>( m_path, js );
529 }
530
531 void SetDefault() override
532 {
533 *m_ptr = m_default;
534 }
535
536 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
537 {
538 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
539 {
540 if( js->is_array() )
541 {
542 std::vector<Type> val;
543
544 for( const auto& el : js->items() )
545 {
546 try
547 {
548 val.emplace_back( el.value().get<Type>() );
549 }
550 catch( ... )
551 {
552 // Probably typecast didn't work; skip this element
553 }
554 }
555
556 return val == *m_ptr;
557 }
558 }
559
560 return false;
561 }
562
563protected:
564 std::vector<Type>* m_ptr;
565 std::vector<Type> m_default;
567};
568
569
570#ifdef __WINDOWS__
571template class KICOMMON_API PARAM_LIST<bool>;
572template class KICOMMON_API PARAM_LIST<int>;
573template class KICOMMON_API PARAM_LIST<double>;
575template class KICOMMON_API PARAM_LIST<GRID>;
577#else
578extern template class APIVISIBLE PARAM_LIST<bool>;
579extern template class APIVISIBLE PARAM_LIST<int>;
580extern template class APIVISIBLE PARAM_LIST<double>;
581extern template class APIVISIBLE PARAM_LIST<KIGFX::COLOR4D>;
582extern template class APIVISIBLE PARAM_LIST<GRID>;
583extern template class APIVISIBLE PARAM_LIST<wxString>;
584#endif
585
586
587template<typename Type>
588class PARAM_SET : public PARAM_BASE
589{
590public:
591 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
592 std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
593 PARAM_BASE( aJsonPath, aReadOnly ),
594 m_ptr( aPtr ),
595 m_default( aDefault )
596 { }
597
598 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
599 std::set<Type> aDefault, bool aReadOnly = false ) :
600 PARAM_BASE( aJsonPath, aReadOnly ),
601 m_ptr( aPtr ),
602 m_default( aDefault )
603 { }
604
605 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
606 {
607 if( m_readOnly )
608 return;
609
610 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
611 {
612 std::set<Type> val;
613
614 if( js->is_array() )
615 {
616 for( const auto& el : js->items() )
617 val.insert( el.value().get<Type>() );
618 }
619
620 *m_ptr = val;
621 }
622 else if( aResetIfMissing )
623 *m_ptr = m_default;
624 }
625
626 void Store( JSON_SETTINGS* aSettings) const override
627 {
628 nlohmann::json js = nlohmann::json::array();
629
630 for( const auto& el : *m_ptr )
631 js.push_back( el );
632
633 aSettings->Set<nlohmann::json>( m_path, js );
634 }
635
636
637 void SetDefault() override
638 {
639 *m_ptr = m_default;
640 }
641
642 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
643 {
644 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
645 {
646 if( js->is_array() )
647 {
648 std::set<Type> val;
649
650 for( const auto& el : js->items() )
651 val.insert( el.value().get<Type>() );
652
653 return val == *m_ptr;
654 }
655 }
656
657 return false;
658 }
659
660protected:
661 std::set<Type>* m_ptr;
662 std::set<Type> m_default;
663};
664
665#ifdef __WINDOWS__
666template class KICOMMON_API PARAM_SET<wxString>;
667#else
668extern template class APIVISIBLE PARAM_SET<wxString>;
669#endif
670
676{
677public:
678 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
679 std::initializer_list<wxString> aDefault ) :
680 PARAM_LIST( aJsonPath, aPtr, aDefault )
681 { }
682
683 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
684 std::vector<wxString> aDefault ) :
685 PARAM_LIST( aJsonPath, aPtr, aDefault )
686 { }
687
688 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
689 {
690 if( m_readOnly )
691 return;
692
693 PARAM_LIST::Load( aSettings, aResetIfMissing );
694
695 for( size_t i = 0; i < m_ptr->size(); i++ )
696 ( *m_ptr )[i] = fromFileFormat( ( *m_ptr )[i] );
697 }
698
699 void Store( JSON_SETTINGS* aSettings) const override;
700
701 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override;
702
703private:
704 wxString toFileFormat( const wxString& aString ) const
705 {
706 wxString ret = aString;
707 ret.Replace( wxT( "\\" ), wxT( "/" ) );
708 return ret;
709 }
710
711 wxString fromFileFormat( const wxString& aString ) const
712 {
713 wxString ret = aString;
714#ifdef __WINDOWS__
715 ret.Replace( wxT( "/" ), wxT( "\\" ) );
716#endif
717 return ret;
718 }
719};
720
733template<typename Value>
734class PARAM_MAP : public PARAM_BASE
735{
736public:
737 PARAM_MAP( const std::string& aJsonPath, std::map<std::string, Value>* aPtr,
738 std::initializer_list<std::pair<const std::string, Value>> aDefault,
739 bool aReadOnly = false ) :
740 PARAM_BASE( aJsonPath, aReadOnly ),
741 m_ptr( aPtr ),
742 m_default( aDefault )
743 {
744 SetClearUnknownKeys( true );
745 }
746
747 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
748 {
749 if( m_readOnly )
750 return;
751
752 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
753 {
754 if( js->is_object() )
755 {
756 m_ptr->clear();
757
758 for( const auto& el : js->items() )
759 ( *m_ptr )[el.key()] = el.value().get<Value>();
760 }
761 }
762 else if( aResetIfMissing )
763 *m_ptr = m_default;
764 }
765
766 void Store( JSON_SETTINGS* aSettings) const override
767 {
768 nlohmann::json js( {} );
769
770 for( const auto& el : *m_ptr )
771 js[el.first] = el.second;
772
773 aSettings->Set<nlohmann::json>( m_path, js );
774 }
775
776 virtual void SetDefault() override
777 {
778 *m_ptr = m_default;
779 }
780
781 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
782 {
783 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
784 {
785 if( js->is_object() )
786 {
787 if( m_ptr->size() != js->size() )
788 return false;
789
790 std::map<std::string, Value> val;
791
792 for( const auto& el : js->items() )
793 val[el.key()] = el.value().get<Value>();
794
795 return val == *m_ptr;
796 }
797 }
798
799 return false;
800 }
801
802private:
803 std::map<std::string, Value>* m_ptr;
804 std::map<std::string, Value> m_default;
805};
806
807
808#ifdef __WINDOWS__
809template class KICOMMON_API PARAM_MAP<int>;
810template class KICOMMON_API PARAM_MAP<double>;
811template class KICOMMON_API PARAM_MAP<bool>;
812#else
813extern template class APIVISIBLE PARAM_MAP<int>;
814extern template class APIVISIBLE PARAM_MAP<double>;
815extern template class APIVISIBLE PARAM_MAP<bool>;
816#endif
817
818
823{
824public:
825 PARAM_WXSTRING_MAP( const std::string& aJsonPath, std::map<wxString, wxString>* aPtr,
826 std::initializer_list<std::pair<const wxString, wxString>> aDefault,
827 bool aReadOnly = false, bool aArrayBehavior = false ) :
828 PARAM_BASE( aJsonPath, aReadOnly ),
829 m_ptr( aPtr ),
830 m_default( aDefault )
831 {
832 m_clearUnknownKeys = aArrayBehavior;
833 }
834
835 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override;
836
837 void Store( JSON_SETTINGS* aSettings) const override;
838
839 virtual void SetDefault() override
840 {
841 *m_ptr = m_default;
842 }
843
844 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override;
845
846private:
847 std::map<wxString, wxString>* m_ptr;
848 std::map<wxString, wxString> m_default;
849};
850
851#endif
KICAD_PLUGIN_EXPORT SCENEGRAPH * Load(char const *aFileName)
Read a model file and creates a generic display structure.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
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< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
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:38
bool m_readOnly
Indicates param pointer should never be overwritten.
Definition parameters.h:84
const std::string & GetJsonPath() const
Definition parameters.h:72
void SetClearUnknownKeys(bool aSet=true)
Definition parameters.h:80
virtual void SetDefault()=0
bool m_clearUnknownKeys
Keys should be cleared from source rather than merged.
Definition parameters.h:85
bool ClearUnknownKeys() const
Definition parameters.h:78
virtual void Store(JSON_SETTINGS *aSettings) const =0
Stores the value of this parameter to the given JSON_SETTINGS object.
virtual ~PARAM_BASE()=default
virtual bool MatchesFile(const JSON_SETTINGS &aSettings) const =0
Checks whether the parameter in memory matches the one in a given JSON file.
std::string m_path
Address of the param in the json files.
Definition parameters.h:83
virtual void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const =0
Loads the value of this parameter from JSON to the underlying storage.
EnumType m_default
Definition parameters.h:287
void SetDefault() override
Definition parameters.h:270
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:241
EnumType GetDefault() const
Definition parameters.h:265
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:275
EnumType * m_ptr
Definition parameters.h:284
PARAM_ENUM(const std::string &aJsonPath, EnumType *aPtr, EnumType aDefault, EnumType aMin, EnumType aMax, bool aReadOnly=false)
Definition parameters.h:231
EnumType m_min
Definition parameters.h:285
EnumType m_max
Definition parameters.h:286
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:260
Like a normal param, but with custom getter and setter functions.
Definition parameters.h:296
std::function< void(ValueType)> m_setter
Definition parameters.h:370
std::function< ValueType()> m_getter
Definition parameters.h:369
ValueType m_default
Definition parameters.h:368
void SetDefault() override
Definition parameters.h:345
ValueType GetDefault() const
Definition parameters.h:340
PARAM_LAMBDA(const std::string &aJsonPath, std::function< ValueType()> aGetter, std::function< void(ValueType)> aSetter, ValueType aDefault, bool aReadOnly=false)
Definition parameters.h:298
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:308
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:350
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:329
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:495
bool m_resetIfEmpty
Definition parameters.h:566
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:521
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:536
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::vector< Type > aDefault, bool aResetIfEmpty=false)
Definition parameters.h:487
std::vector< Type > * m_ptr
Definition parameters.h:564
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::initializer_list< Type > aDefault, bool aResetIfEmpty=false)
Definition parameters.h:479
std::vector< Type > m_default
Definition parameters.h:565
void SetDefault() override
Definition parameters.h:531
Represents a map of <std::string, Value>.
Definition parameters.h:735
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:747
virtual void SetDefault() override
Definition parameters.h:776
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:737
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:766
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:781
std::map< std::string, Value > m_default
Definition parameters.h:804
std::map< std::string, Value > * m_ptr
Definition parameters.h:803
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::vector< wxString > aDefault)
Definition parameters.h:683
wxString toFileFormat(const wxString &aString) const
Definition parameters.h:704
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::initializer_list< wxString > aDefault)
Definition parameters.h:678
wxString fromFileFormat(const wxString &aString) const
Definition parameters.h:711
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:688
PARAM_PATH(const std::string &aJsonPath, wxString *aPtr, const wxString &aDefault, bool aReadOnly=false)
Definition parameters.h:177
wxString fromFileFormat(const wxString &aString) const
Definition parameters.h:213
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:197
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:192
wxString toFileFormat(const wxString &aString) const
Definition parameters.h:206
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:182
ValueType GetDefault() const
Definition parameters.h:447
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:419
bool m_use_minmax
Definition parameters.h:470
ValueType m_default
Definition parameters.h:467
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:442
ValueType m_max
Definition parameters.h:469
double m_scale
Definition parameters.h:471
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:457
ValueType * m_ptr
Definition parameters.h:466
double m_invScale
Definition parameters.h:472
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, double aScale=1.0, bool aReadOnly=false)
Definition parameters.h:395
virtual void SetDefault() override
Definition parameters.h:452
ValueType m_min
Definition parameters.h:468
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, double aScale=1.0, bool aReadOnly=false)
Definition parameters.h:407
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:642
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::initializer_list< Type > aDefault, bool aReadOnly=false)
Definition parameters.h:591
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::set< Type > aDefault, bool aReadOnly=false)
Definition parameters.h:598
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:605
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:626
std::set< Type > * m_ptr
Definition parameters.h:661
void SetDefault() override
Definition parameters.h:637
std::set< Type > m_default
Definition parameters.h:662
virtual void SetDefault() override
Definition parameters.h:839
std::map< wxString, wxString > * m_ptr
Definition parameters.h:847
PARAM_WXSTRING_MAP(const std::string &aJsonPath, std::map< wxString, wxString > *aPtr, std::initializer_list< std::pair< const wxString, wxString > > aDefault, bool aReadOnly=false, bool aArrayBehavior=false)
Definition parameters.h:825
std::map< wxString, wxString > m_default
Definition parameters.h:848
void Load(const JSON_SETTINGS &aSettings, bool aResetIfMissing=true) const override
Loads the value of this parameter from JSON to the underlying storage.
Definition parameters.h:115
PARAM(const std::string &aJsonPath, ValueType *aPtr, const ValueType &aDefault, bool aReadOnly=false)
Definition parameters.h:95
bool MatchesFile(const JSON_SETTINGS &aSettings) const override
Checks whether the parameter in memory matches the one in a given JSON file.
Definition parameters.h:153
void SetDefault() override
Definition parameters.h:148
ValueType * m_ptr
Definition parameters.h:167
ValueType m_default
Definition parameters.h:168
bool m_use_minmax
Definition parameters.h:164
PARAM(const std::string &aJsonPath, ValueType *aPtr, const ValueType &aDefault, const ValueType &aMin, const ValueType &aMax, bool aReadOnly=false)
Definition parameters.h:105
ValueType GetDefault() const
Definition parameters.h:143
ValueType m_min
Definition parameters.h:162
ValueType m_max
Definition parameters.h:163
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition parameters.h:138
#define APIVISIBLE
#define KICOMMON_API
Definition kicommon.h:28
STL namespace.