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
189 *m_ptr = fromFileFormat( *m_ptr );
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 ret.Replace( wxT( "/" ), wxT( "\\" ) );
218#endif
219 return ret;
220 }
221};
222
226template<typename EnumType>
227class PARAM_ENUM : public PARAM_BASE
228{
229public:
230 PARAM_ENUM( const std::string& aJsonPath, EnumType* aPtr, EnumType aDefault,
231 EnumType aMin, EnumType aMax, bool aReadOnly = false ) :
232 PARAM_BASE( aJsonPath, aReadOnly ),
233 m_ptr( aPtr ),
234 m_min( aMin ),
235 m_max( aMax ),
236 m_default( aDefault )
237 {
238 }
239
240 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
241 {
242 if( m_readOnly )
243 return;
244
245 if( std::optional<int> val = aSettings.Get<int>( m_path ) )
246 {
247 if( *val >= static_cast<int>( m_min ) && *val <= static_cast<int>( m_max ) )
248 *m_ptr = static_cast<EnumType>( *val );
249 else if( aResetIfMissing )
250 *m_ptr = m_default;
251
252 }
253 else if( aResetIfMissing )
254 {
255 *m_ptr = m_default;
256 }
257 }
258
259 void Store( JSON_SETTINGS* aSettings ) const override
260 {
261 aSettings->Set<int>( m_path, static_cast<int>( *m_ptr ) );
262 }
263
264 EnumType GetDefault() const
265 {
266 return m_default;
267 }
268
269 void SetDefault() override
270 {
271 *m_ptr = m_default;
272 }
273
274 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
275 {
276 if( std::optional<int> val = aSettings.Get<int>( m_path ) )
277 return *val == static_cast<int>( *m_ptr );
278
279 return false;
280 }
281
282private:
283 EnumType* m_ptr;
284 EnumType m_min;
285 EnumType m_max;
286 EnumType m_default;
287};
288
293template<typename ValueType>
295{
296public:
297 PARAM_LAMBDA( const std::string& aJsonPath, std::function<ValueType()> aGetter,
298 std::function<void( ValueType )> aSetter, ValueType aDefault,
299 bool aReadOnly = false ) :
300 PARAM_BASE( aJsonPath, aReadOnly ),
301 m_default( std::move( aDefault ) ),
302 m_getter( std::move( aGetter ) ),
303 m_setter( std::move( aSetter ) )
304 {
305 }
306
307 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
308 {
309 if( m_readOnly )
310 return;
311
312 if( std::is_same<ValueType, nlohmann::json>::value )
313 {
314 if( std::optional<nlohmann::json> optval = aSettings.GetJson( m_path ) )
315 m_setter( *optval );
316 else
318 }
319 else
320 {
321 if( std::optional<ValueType> optval = aSettings.Get<ValueType>( m_path ) )
322 m_setter( *optval );
323 else
325 }
326 }
327
328 void Store( JSON_SETTINGS* aSettings ) const override
329 {
330 try
331 {
332 aSettings->Set<ValueType>( m_path, m_getter() );
333 }
334 catch( ... )
335 {
336 }
337 }
338
339 ValueType GetDefault() const
340 {
341 return m_default;
342 }
343
344 void SetDefault() override
345 {
347 }
348
349 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
350 {
351 if( std::is_same<ValueType, nlohmann::json>::value )
352 {
353 if( std::optional<nlohmann::json> optval = aSettings.GetJson( m_path ) )
354 return *optval == m_getter();
355 }
356 else
357 {
358 if( std::optional<ValueType> optval = aSettings.Get<ValueType>( m_path ) )
359 return *optval == m_getter();
360 }
361
362 // Not in file
363 return false;
364 }
365
366private:
367 ValueType m_default;
368 std::function<ValueType()> m_getter;
369 std::function<void( ValueType )> m_setter;
370};
371
372#ifdef __WINDOWS__
373template class KICOMMON_API PARAM_LAMBDA<bool>;
374template class KICOMMON_API PARAM_LAMBDA<int>;
377#else
378extern template class APIVISIBLE PARAM_LAMBDA<bool>;
379extern template class APIVISIBLE PARAM_LAMBDA<int>;
380extern template class APIVISIBLE PARAM_LAMBDA<nlohmann::json>;
381extern template class APIVISIBLE PARAM_LAMBDA<std::string>;
382#endif
383
390template<typename ValueType>
392{
393public:
394 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
395 double aScale = 1.0, bool aReadOnly = false ) :
396 PARAM_BASE( aJsonPath, aReadOnly ),
397 m_ptr( aPtr ),
398 m_default( aDefault ),
399 m_min(),
400 m_max(),
401 m_use_minmax( false ),
402 m_scale( aScale ),
403 m_invScale( 1.0 / aScale )
404 { }
405
406 PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault,
407 ValueType aMin, ValueType aMax, double aScale = 1.0, bool aReadOnly = false ) :
408 PARAM_BASE( aJsonPath, aReadOnly ),
409 m_ptr( aPtr ),
410 m_default( aDefault ),
411 m_min( aMin ),
412 m_max( aMax ),
413 m_use_minmax( true ),
414 m_scale( aScale ),
415 m_invScale( 1.0 / aScale )
416 { }
417
418 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
419 {
420 if( m_readOnly )
421 return;
422
423 double dval = m_default / m_invScale;
424
425 if( std::optional<double> optval = aSettings.Get<double>( m_path ) )
426 dval = *optval;
427 else if( !aResetIfMissing )
428 return;
429
430 ValueType val = KiROUND<double, ValueType>( dval * m_invScale );
431
432 if( m_use_minmax )
433 {
434 if( val > m_max || val < m_min )
435 val = m_default;
436 }
437
438 *m_ptr = val;
439 }
440
441 void Store( JSON_SETTINGS* aSettings) const override
442 {
443 aSettings->Set<double>( m_path, *m_ptr / m_invScale );
444 }
445
446 ValueType GetDefault() const
447 {
448 return m_default;
449 }
450
451 virtual void SetDefault() override
452 {
453 *m_ptr = m_default;
454 }
455
456 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
457 {
458 if( std::optional<double> optval = aSettings.Get<double>( m_path ) )
459 return *optval == ( *m_ptr / m_invScale );
460
461 return false;
462 }
463
464private:
465 ValueType* m_ptr;
466 ValueType m_default;
467 ValueType m_min;
468 ValueType m_max;
470 double m_scale;
472};
473
474template<typename Type>
475class PARAM_LIST : public PARAM_BASE
476{
477public:
478 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
479 std::initializer_list<Type> aDefault, bool aResetIfEmpty = false ) :
480 PARAM_BASE( aJsonPath, false ),
481 m_ptr( aPtr ),
482 m_default( aDefault ),
483 m_resetIfEmpty( aResetIfEmpty )
484 { }
485
486 PARAM_LIST( const std::string& aJsonPath, std::vector<Type>* aPtr,
487 std::vector<Type> aDefault, bool aResetIfEmpty = false ) :
488 PARAM_BASE( aJsonPath, false ),
489 m_ptr( aPtr ),
490 m_default( std::move( aDefault ) ),
491 m_resetIfEmpty( aResetIfEmpty )
492 { }
493
494 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
495 {
496 if( m_readOnly )
497 return;
498
499 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
500 {
501 std::vector<Type> val;
502
503 if( js->is_array() )
504 {
505 for( const auto& el : js->items() )
506 val.push_back( el.value().get<Type>() );
507 }
508
509 if( val.empty() && m_resetIfEmpty )
510 *m_ptr = m_default;
511 else
512 *m_ptr = val;
513 }
514 else if( aResetIfMissing )
515 {
516 *m_ptr = m_default;
517 }
518 }
519
520 void Store( JSON_SETTINGS* aSettings ) const override
521 {
522 nlohmann::json js = nlohmann::json::array();
523
524 for( const auto& el : *m_ptr )
525 js.push_back( el );
526
527 aSettings->Set<nlohmann::json>( m_path, js );
528 }
529
530 void SetDefault() override
531 {
532 *m_ptr = m_default;
533 }
534
535 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
536 {
537 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
538 {
539 if( js->is_array() )
540 {
541 std::vector<Type> val;
542
543 for( const auto& el : js->items() )
544 {
545 try
546 {
547 val.emplace_back( el.value().get<Type>() );
548 }
549 catch( ... )
550 {
551 // Probably typecast didn't work; skip this element
552 }
553 }
554
555 return val == *m_ptr;
556 }
557 }
558
559 return false;
560 }
561
562protected:
563 std::vector<Type>* m_ptr;
564 std::vector<Type> m_default;
566};
567
568
569#ifdef __WINDOWS__
570template class KICOMMON_API PARAM_LIST<bool>;
571template class KICOMMON_API PARAM_LIST<int>;
572template class KICOMMON_API PARAM_LIST<double>;
574template class KICOMMON_API PARAM_LIST<GRID>;
576#else
577extern template class APIVISIBLE PARAM_LIST<bool>;
578extern template class APIVISIBLE PARAM_LIST<int>;
579extern template class APIVISIBLE PARAM_LIST<double>;
580extern template class APIVISIBLE PARAM_LIST<KIGFX::COLOR4D>;
581extern template class APIVISIBLE PARAM_LIST<GRID>;
582extern template class APIVISIBLE PARAM_LIST<wxString>;
583#endif
584
585
586template<typename Type>
587class PARAM_SET : public PARAM_BASE
588{
589public:
590 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
591 std::initializer_list<Type> aDefault, bool aReadOnly = false ) :
592 PARAM_BASE( aJsonPath, aReadOnly ),
593 m_ptr( aPtr ),
594 m_default( aDefault )
595 { }
596
597 PARAM_SET( const std::string& aJsonPath, std::set<Type>* aPtr,
598 std::set<Type> aDefault, bool aReadOnly = false ) :
599 PARAM_BASE( aJsonPath, aReadOnly ),
600 m_ptr( aPtr ),
601 m_default( aDefault )
602 { }
603
604 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
605 {
606 if( m_readOnly )
607 return;
608
609 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
610 {
611 std::set<Type> val;
612
613 if( js->is_array() )
614 {
615 for( const auto& el : js->items() )
616 val.insert( el.value().get<Type>() );
617 }
618
619 *m_ptr = val;
620 }
621 else if( aResetIfMissing )
622 *m_ptr = m_default;
623 }
624
625 void Store( JSON_SETTINGS* aSettings) const override
626 {
627 nlohmann::json js = nlohmann::json::array();
628
629 for( const auto& el : *m_ptr )
630 js.push_back( el );
631
632 aSettings->Set<nlohmann::json>( m_path, js );
633 }
634
635
636 void SetDefault() override
637 {
638 *m_ptr = m_default;
639 }
640
641 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
642 {
643 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
644 {
645 if( js->is_array() )
646 {
647 std::set<Type> val;
648
649 for( const auto& el : js->items() )
650 val.insert( el.value().get<Type>() );
651
652 return val == *m_ptr;
653 }
654 }
655
656 return false;
657 }
658
659protected:
660 std::set<Type>* m_ptr;
661 std::set<Type> m_default;
662};
663
664#ifdef __WINDOWS__
665template class KICOMMON_API PARAM_SET<wxString>;
666#else
667extern template class APIVISIBLE PARAM_SET<wxString>;
668#endif
669
675{
676public:
677 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
678 std::initializer_list<wxString> aDefault ) :
679 PARAM_LIST( aJsonPath, aPtr, aDefault )
680 { }
681
682 PARAM_PATH_LIST( const std::string& aJsonPath, std::vector<wxString>* aPtr,
683 std::vector<wxString> aDefault ) :
684 PARAM_LIST( aJsonPath, aPtr, aDefault )
685 { }
686
687 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
688 {
689 if( m_readOnly )
690 return;
691
692 PARAM_LIST::Load( aSettings, aResetIfMissing );
693
694 for( size_t i = 0; i < m_ptr->size(); i++ )
695 ( *m_ptr )[i] = fromFileFormat( ( *m_ptr )[i] );
696 }
697
698 void Store( JSON_SETTINGS* aSettings) const override;
699
700 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override;
701
702private:
703 wxString toFileFormat( const wxString& aString ) const
704 {
705 wxString ret = aString;
706 ret.Replace( wxT( "\\" ), wxT( "/" ) );
707 return ret;
708 }
709
710 wxString fromFileFormat( const wxString& aString ) const
711 {
712 wxString ret = aString;
713#ifdef __WINDOWS__
714 ret.Replace( wxT( "/" ), wxT( "\\" ) );
715#endif
716 return ret;
717 }
718};
719
732template<typename Value>
733class PARAM_MAP : public PARAM_BASE
734{
735public:
736 PARAM_MAP( const std::string& aJsonPath, std::map<std::string, Value>* aPtr,
737 std::initializer_list<std::pair<const std::string, Value>> aDefault,
738 bool aReadOnly = false ) :
739 PARAM_BASE( aJsonPath, aReadOnly ),
740 m_ptr( aPtr ),
741 m_default( aDefault )
742 {
743 SetClearUnknownKeys( true );
744 }
745
746 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override
747 {
748 if( m_readOnly )
749 return;
750
751 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
752 {
753 if( js->is_object() )
754 {
755 m_ptr->clear();
756
757 for( const auto& el : js->items() )
758 ( *m_ptr )[el.key()] = el.value().get<Value>();
759 }
760 }
761 else if( aResetIfMissing )
762 *m_ptr = m_default;
763 }
764
765 void Store( JSON_SETTINGS* aSettings) const override
766 {
767 nlohmann::json js( {} );
768
769 for( const auto& el : *m_ptr )
770 js[el.first] = el.second;
771
772 aSettings->Set<nlohmann::json>( m_path, js );
773 }
774
775 virtual void SetDefault() override
776 {
777 *m_ptr = m_default;
778 }
779
780 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override
781 {
782 if( std::optional<nlohmann::json> js = aSettings.GetJson( m_path ) )
783 {
784 if( js->is_object() )
785 {
786 if( m_ptr->size() != js->size() )
787 return false;
788
789 std::map<std::string, Value> val;
790
791 for( const auto& el : js->items() )
792 val[el.key()] = el.value().get<Value>();
793
794 return val == *m_ptr;
795 }
796 }
797
798 return false;
799 }
800
801private:
802 std::map<std::string, Value>* m_ptr;
803 std::map<std::string, Value> m_default;
804};
805
806
807#ifdef __WINDOWS__
808template class KICOMMON_API PARAM_MAP<int>;
809template class KICOMMON_API PARAM_MAP<double>;
810template class KICOMMON_API PARAM_MAP<bool>;
811#else
812extern template class APIVISIBLE PARAM_MAP<int>;
813extern template class APIVISIBLE PARAM_MAP<double>;
814extern template class APIVISIBLE PARAM_MAP<bool>;
815#endif
816
817
822{
823public:
824 PARAM_WXSTRING_MAP( const std::string& aJsonPath, std::map<wxString, wxString>* aPtr,
825 std::initializer_list<std::pair<const wxString, wxString>> aDefault,
826 bool aReadOnly = false, bool aArrayBehavior = false ) :
827 PARAM_BASE( aJsonPath, aReadOnly ),
828 m_ptr( aPtr ),
829 m_default( aDefault )
830 {
831 m_clearUnknownKeys = aArrayBehavior;
832 }
833
834 void Load( const JSON_SETTINGS& aSettings, bool aResetIfMissing = true ) const override;
835
836 void Store( JSON_SETTINGS* aSettings) const override;
837
838 virtual void SetDefault() override
839 {
840 *m_ptr = m_default;
841 }
842
843 bool MatchesFile( const JSON_SETTINGS& aSettings ) const override;
844
845private:
846 std::map<wxString, wxString>* m_ptr;
847 std::map<wxString, wxString> m_default;
848};
849
850#endif
KICAD_PLUGIN_EXPORT SCENEGRAPH * Load(char const *aFileName)
Read a model file and creates a generic display structure.
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.
Stores an enum as an integer.
Definition: parameters.h:228
EnumType m_default
Definition: parameters.h:286
void SetDefault() override
Definition: parameters.h:269
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:240
EnumType GetDefault() const
Definition: parameters.h:264
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:274
EnumType * m_ptr
Definition: parameters.h:283
PARAM_ENUM(const std::string &aJsonPath, EnumType *aPtr, EnumType aDefault, EnumType aMin, EnumType aMax, bool aReadOnly=false)
Definition: parameters.h:230
EnumType m_min
Definition: parameters.h:284
EnumType m_max
Definition: parameters.h:285
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:259
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:295
std::function< void(ValueType)> m_setter
Definition: parameters.h:369
std::function< ValueType()> m_getter
Definition: parameters.h:368
ValueType m_default
Definition: parameters.h:367
void SetDefault() override
Definition: parameters.h:344
ValueType GetDefault() const
Definition: parameters.h:339
PARAM_LAMBDA(const std::string &aJsonPath, std::function< ValueType()> aGetter, std::function< void(ValueType)> aSetter, ValueType aDefault, bool aReadOnly=false)
Definition: parameters.h:297
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:307
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:349
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:328
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:494
bool m_resetIfEmpty
Definition: parameters.h:565
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:520
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:535
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::vector< Type > aDefault, bool aResetIfEmpty=false)
Definition: parameters.h:486
std::vector< Type > * m_ptr
Definition: parameters.h:563
PARAM_LIST(const std::string &aJsonPath, std::vector< Type > *aPtr, std::initializer_list< Type > aDefault, bool aResetIfEmpty=false)
Definition: parameters.h:478
std::vector< Type > m_default
Definition: parameters.h:564
void SetDefault() override
Definition: parameters.h:530
Represents a map of <std::string, Value>.
Definition: parameters.h:734
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:746
virtual void SetDefault() override
Definition: parameters.h:775
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:736
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:765
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:780
std::map< std::string, Value > m_default
Definition: parameters.h:803
std::map< std::string, Value > * m_ptr
Definition: parameters.h:802
Represents a list of strings holding directory paths.
Definition: parameters.h:675
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::vector< wxString > aDefault)
Definition: parameters.h:682
wxString toFileFormat(const wxString &aString) const
Definition: parameters.h:703
PARAM_PATH_LIST(const std::string &aJsonPath, std::vector< wxString > *aPtr, std::initializer_list< wxString > aDefault)
Definition: parameters.h:677
wxString fromFileFormat(const wxString &aString) const
Definition: parameters.h:710
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:687
Stores a path as a string with directory separators normalized to unix-style.
Definition: parameters.h:175
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
Represents a parameter that has a scaling factor between the value in the file and the value used int...
Definition: parameters.h:392
ValueType GetDefault() const
Definition: parameters.h:446
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:418
bool m_use_minmax
Definition: parameters.h:469
ValueType m_default
Definition: parameters.h:466
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:441
ValueType m_max
Definition: parameters.h:468
double m_scale
Definition: parameters.h:470
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:456
ValueType * m_ptr
Definition: parameters.h:465
double m_invScale
Definition: parameters.h:471
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:394
virtual void SetDefault() override
Definition: parameters.h:451
ValueType m_min
Definition: parameters.h:467
PARAM_SCALED(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault, ValueType aMin, ValueType aMax, double aScale=1.0, bool aReadOnly=false)
Definition: parameters.h:406
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:641
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::initializer_list< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:590
PARAM_SET(const std::string &aJsonPath, std::set< Type > *aPtr, std::set< Type > aDefault, bool aReadOnly=false)
Definition: parameters.h:597
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:604
void Store(JSON_SETTINGS *aSettings) const override
Stores the value of this parameter to the given JSON_SETTINGS object.
Definition: parameters.h:625
std::set< Type > * m_ptr
Definition: parameters.h:660
void SetDefault() override
Definition: parameters.h:636
std::set< Type > m_default
Definition: parameters.h:661
A helper for <wxString, wxString> maps.
Definition: parameters.h:822
virtual void SetDefault() override
Definition: parameters.h:838
std::map< wxString, wxString > * m_ptr
Definition: parameters.h:846
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:824
std::map< wxString, wxString > m_default
Definition: parameters.h:847
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
Definition: import_export.h:55
#define KICOMMON_API
Definition: kicommon.h:28
STL namespace.