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