11#ifndef __AUDACITY_SHUTTLE_AUTOMATION__
12#define __AUDACITY_SHUTTLE_AUTOMATION__
59template <
typename EffectType,
const auto &...Parameters>
62 using Params = std::remove_pointer_t<
decltype(
64 EffectType::FetchParameters(
65 std::declval<EffectType&>(), std::declval<EffectSettings &>())
81 template<
typename Fn,
83 typename =
decltype( std::declval<Fn>()(
84 std::declval<EffectType &>(), std::declval<EffectSettings &>(),
85 std::declval<Params &>(),
true) )
96 if (
auto pStruct = EffectType::FetchParameters(
98 DoReset(effect, dummy, *pStruct, *
this);
103 if (
auto pStruct = EffectType::FetchParameters(
105 DoVisit<false>(*pStruct, visitor);
111 auto &nonconstEffect =
const_cast<Effect&
>(effect);
115 if (
auto pStruct = EffectType::FetchParameters(
116 static_cast<EffectType&
>(nonconstEffect), nonconstSettings))
122 auto &nonconstEffect =
const_cast<Effect &
>(effect);
126 if (
auto pStruct = EffectType::FetchParameters(
127 static_cast<EffectType&
>(nonconstEffect), nonconstSettings))
128 DoGet(*pStruct, parms);
132 if (
auto pStruct = EffectType::FetchParameters(
146 template<
typename Member,
typename Type,
typename Value >
150 structure.*(param.
mem) = param.
def;
155 (
ResetOne(structure, Parameters), ...);
162 template<
bool Const,
typename Member,
typename Type,
typename Value >
167 static_cast<Member
>(param.
def),
168 static_cast<Member
>(param.
min),
169 static_cast<Member
>(param.
max),
170 static_cast<Member
>(param.
scale) );
173 template<
bool Const,
typename Member >
182 (VisitOne<Const>(structure, visitor, Parameters), ...);
185 template<
typename Member,
typename Type,
typename Value >
189 parms.Write( param.
key,
static_cast<Value
>(structure.*(param.
mem)) );
192 template<
typename Member >
200 (
GetOne(structure, parms, Parameters), ...);
203 template<
typename Member,
typename Type,
typename Value >
212 structure.*(param.
mem) = temp;
216 template<
typename Member >
225 structure.*(param.
mem) = temp;
231 if (!(
SetOne(structure, parms, Parameters) && ...))
249 void Define(
bool var,
const wxChar *
key,
bool vdefault,
250 bool vmin,
bool vmax,
bool vscl)
override;
251 void Define(
int var,
const wxChar *
key,
int vdefault,
252 int vmin,
int vmax,
int vscl)
override;
253 void Define(
size_t var,
const wxChar *
key,
int vdefault,
254 int vmin,
int vmax,
int vscl)
override;
255 void Define(
float var,
const wxChar *
key,
float vdefault,
256 float vmin,
float vmax,
float vscl)
override;
257 void Define(
double var,
const wxChar *
key,
float vdefault,
258 float vmin,
float vmax,
float vscl)
override;
259 void Define(
double var,
const wxChar *
key,
double vdefault,
260 double vmin,
double vmax,
double vscl)
override;
261 void Define(
const wxString &var,
const wxChar *
key, wxString vdefault,
262 wxString vmin, wxString vmax, wxString vscl)
override;
263 void DefineEnum(
int var,
const wxChar *
key,
int vdefault,
275 bool bWrite{
false };
277 bool CouldGet(
const wxString &
key);
290 void Define(
bool & var,
const wxChar *
key,
bool vdefault,
291 bool vmin,
bool vmax,
bool vscl )
override;
292 void Define(
int & var,
const wxChar *
key,
int vdefault,
293 int vmin,
int vmax,
int vscl )
override;
294 void Define(
size_t & var,
const wxChar *
key,
int vdefault,
295 int vmin,
int vmax,
int vscl )
override;
296 void Define(
float & var,
const wxChar *
key,
float vdefault,
297 float vmin,
float vmax,
float vscl )
override;
298 void Define(
double & var,
const wxChar *
key,
float vdefault,
299 float vmin,
float vmax,
float vscl )
override;
300 void Define(
double & var,
const wxChar *
key,
double vdefault,
301 double vmin,
double vmax,
double vscl )
override;
302 void Define( wxString &var,
const wxChar *
key, wxString vdefault,
303 wxString vmin, wxString vmax, wxString vscl )
override;
304 void DefineEnum(
int &var,
const wxChar *
key,
int vdefault,
319 void Define(
bool & var,
const wxChar *
key,
bool vdefault,
320 bool vmin,
bool vmax,
bool vscl )
override;
321 void Define(
int & var,
const wxChar *
key,
int vdefault,
322 int vmin,
int vmax,
int vscl )
override;
323 void Define(
size_t & var,
const wxChar *
key,
int vdefault,
324 int vmin,
int vmax,
int vscl )
override;
325 void Define(
float & var,
const wxChar *
key,
float vdefault,
326 float vmin,
float vmax,
float vscl )
override;
327 void Define(
double & var,
const wxChar *
key,
float vdefault,
328 float vmin,
float vmax,
float vscl )
override;
329 void Define(
double & var,
const wxChar *
key,
double vdefault,
330 double vmin,
double vmax,
double vscl )
override;
331 void Define( wxString &var,
const wxChar *
key, wxString vdefault,
332 wxString vmin, wxString vmax, wxString vscl )
override;
333 void DefineEnum(
int &var,
const wxChar *
key,
int vdefault,
static Settings & settings()
Generates EffectParameterMethods overrides from variadic template arguments.
static bool DoSet(Effect &effect, EffectSettings &settings, Params &structure, const CapturedParameters &This, const CommandParameters &parms)
static bool SetOne(Params &structure, const CommandParameters &parms, const EffectParameter< Params, Member, Type, Value > ¶m)
void Visit(Effect &effect, SettingsVisitor &visitor, EffectSettings &settings) const override
bool Set(Effect &effect, const CommandParameters &parms, EffectSettings &settings) const override
static void DoReset(Effect &effect, EffectSettings settings, Params &structure, const CapturedParameters &This)
CapturedParameters(Fn &&PostSet)
std::function< bool(EffectType &, EffectSettings &, Params &, bool) > PostSetFunction
static void DoGet(const Params &structure, CommandParameters &parms)
static void GetOne(const Params &structure, CommandParameters &parms, const EnumParameter< Params, Member > ¶m)
virtual ~CapturedParameters()=default
PostSetFunction PostSetFn
static void VisitOne(Params &structure, SettingsVisitorBase< Const > &visitor, const EffectParameter< Params, Member, Type, Value > ¶m)
static void GetOne(const Params &structure, CommandParameters &parms, const EffectParameter< Params, Member, Type, Value > ¶m)
static bool SetOne(Params &structure, const CommandParameters &parms, const EnumParameter< Params, Member > ¶m)
void Visit(const Effect &effect, ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
static void VisitOne(Params &structure, SettingsVisitorBase< Const > &visitor, const EnumParameter< Params, Member > ¶m)
void Get(const Effect &effect, const EffectSettings &settings, CommandParameters &parms) const override
static void ResetOne(Params &structure, const EffectParameter< Params, Member, Type, Value > ¶m)
std::remove_pointer_t< decltype(EffectType::FetchParameters(std::declval< EffectType & >(), std::declval< EffectSettings & >())) > Params
void Reset(Effect &effect) const override
static void DoVisit(Params &structure, SettingsVisitorBase< Const > &visitor)
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool ReadAndVerify(const wxString &key, float *val, float defVal, float min, float max) const
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
const wxString & Internal() const
Base class for many of the effects in Audacity.
Interface for manipulations of an Effect's settings.
virtual bool Set(Effect &effect, const CommandParameters &parms, EffectSettings &settings) const =0
virtual void Get(const Effect &effect, const EffectSettings &settings, CommandParameters &parms) const =0
virtual void Visit(Effect &effect, SettingsVisitor &visitor, EffectSettings &settings) const =0
virtual void Visit(const Effect &effect, ConstSettingsVisitor &visitor, const EffectSettings &settings) const =0
virtual void Reset(Effect &effect) const =0
virtual ~EffectParameterMethods()
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 void DefineEnum(Arg< int > var, const wxChar *key, int vdefault, const EnumValueSymbol strings[], size_t nStrings)
SettingsVisitor that sets parameters to their default values.
SettingsVisitor that gets parameter values into a string.
SettingsVisitor that sets parameters to a value (from a string)
void SetForValidating(CommandParameters *pEap)
void SetForWriting(CommandParameters *pEap)
const wxChar *const key
Identifier in configuration file.
const Type scale
Scaling factor, for slider control.
Member Structure::*const mem
Member holding the parameter.
const Type def
Default value.
const Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.
const EnumValueSymbol *const symbols