Audacity 3.2.0
SettingsVisitor.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 SettingsVisitor.cpp
4
5 James Crook
6 (C) Audacity Developers, 2007
7
8 wxWidgets license. See Licensing.txt
9
10*//*******************************************************************/
11#include "SettingsVisitor.h"
12
13#ifdef _MSC_VER
14// If this is compiled with MSVC (Visual Studio)
15#pragma warning( push )
16#pragma warning( disable: 4100 ) // unused parameters.
17#endif //_MSC_VER
18
19
20// The ShouldSet and CouldGet functions have an important side effect
21// on the pOptionalFlag. They 'use it up' and clear it down for the next parameter.
22
23
24template<bool Const>
26
27template<bool Const>
30{
31 pOptionalFlag = nullptr;
32 return *this;
33}
34
35template<bool Const>
38{
39 return Optional( var );
40}
41
42template<bool Const>
45{
46 return Optional( var );
47}
48
49// Tests for parameter being optional.
50// Prepares for next parameter by clearing the pointer.
51// Reports on whether the parameter should be set, i.e. should set
52// if it was chosen to be set, or was not optional.
53template<bool Const>
55{
56 if( !pOptionalFlag )
57 return true;
58 bool result = *pOptionalFlag;
59 pOptionalFlag = NULL;
60 return result;
61}
62
63// These are functions to override. They do nothing.
64template<bool Const>
66 bool, bool, bool, bool)
67{}
68
69template<bool Const>
71 int, int, int, int)
72{}
73
74template<bool Const>
76 int, int, int, int)
77{}
78
79template<bool Const>
81 Arg<float>, const wxChar *, float, float, float, float)
82{}
83
84template<bool Const>
86 Arg<double>, const wxChar *, float, float, float, float )
87{}
88
89template<bool Const>
91 Arg<double>, const wxChar *, double, double, double, double)
92{}
93
94template<bool Const>
96 Ref<wxString>, const wxChar *, wxString, wxString, wxString, wxString)
97{}
98
99template<bool Const>
101 Arg<int>, const wxChar *, int, const EnumValueSymbol [], size_t)
102{}
103
104// Explicit instantiations
105template class SettingsVisitorBase<false>;
106template class SettingsVisitorBase<true>;
107
108#ifdef _MSC_VER
109// If this is compiled with MSVC (Visual Studio)
110#pragma warning( pop )
111#endif //_MSC_VER
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
virtual void Define(Arg< bool > var, const wxChar *key, bool vdefault, bool vmin=false, bool vmax=false, bool vscl=false)
virtual SettingsVisitorBase & OptionalY(Ref< bool > var)
std::conditional_t< Const, T, T & > Arg
virtual ~SettingsVisitorBase()
virtual SettingsVisitorBase & Optional(Ref< bool > var)
virtual void DefineEnum(Arg< int > var, const wxChar *key, int vdefault, const EnumValueSymbol strings[], size_t nStrings)
std::conditional_t< Const, const T &, T & > Ref
virtual SettingsVisitorBase & OptionalN(Ref< bool > var)