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) && ...))
248 void Define(
bool var,
const wxChar *
key,
bool vdefault,
249 bool vmin,
bool vmax,
bool vscl)
override;
250 void Define(
int var,
const wxChar *
key,
int vdefault,
251 int vmin,
int vmax,
int vscl)
override;
252 void Define(
size_t var,
const wxChar *
key,
int vdefault,
253 int vmin,
int vmax,
int vscl)
override;
254 void Define(
float var,
const wxChar *
key,
float vdefault,
255 float vmin,
float vmax,
float vscl)
override;
256 void Define(
double var,
const wxChar *
key,
float vdefault,
257 float vmin,
float vmax,
float vscl)
override;
258 void Define(
double var,
const wxChar *
key,
double vdefault,
259 double vmin,
double vmax,
double vscl)
override;
260 void Define(
const wxString &var,
const wxChar *
key, wxString vdefault,
261 wxString vmin, wxString vmax, wxString vscl)
override;
262 void DefineEnum(
int var,
const wxChar *
key,
int vdefault,
274 bool bWrite{
false };
276 bool CouldGet(
const wxString &
key);
289 void Define(
bool & var,
const wxChar *
key,
bool vdefault,
290 bool vmin,
bool vmax,
bool vscl )
override;
291 void Define(
int & var,
const wxChar *
key,
int vdefault,
292 int vmin,
int vmax,
int vscl )
override;
293 void Define(
size_t & var,
const wxChar *
key,
int vdefault,
294 int vmin,
int vmax,
int vscl )
override;
295 void Define(
float & var,
const wxChar *
key,
float vdefault,
296 float vmin,
float vmax,
float vscl )
override;
297 void Define(
double & var,
const wxChar *
key,
float vdefault,
298 float vmin,
float vmax,
float vscl )
override;
299 void Define(
double & var,
const wxChar *
key,
double vdefault,
300 double vmin,
double vmax,
double vscl )
override;
301 void Define( wxString &var,
const wxChar *
key, wxString vdefault,
302 wxString vmin, wxString vmax, wxString vscl )
override;
303 void DefineEnum(
int &var,
const wxChar *
key,
int vdefault,
318 void Define(
bool & var,
const wxChar *
key,
bool vdefault,
319 bool vmin,
bool vmax,
bool vscl )
override;
320 void Define(
int & var,
const wxChar *
key,
int vdefault,
321 int vmin,
int vmax,
int vscl )
override;
322 void Define(
size_t & var,
const wxChar *
key,
int vdefault,
323 int vmin,
int vmax,
int vscl )
override;
324 void Define(
float & var,
const wxChar *
key,
float vdefault,
325 float vmin,
float vmax,
float vscl )
override;
326 void Define(
double & var,
const wxChar *
key,
float vdefault,
327 float vmin,
float vmax,
float vscl )
override;
328 void Define(
double & var,
const wxChar *
key,
double vdefault,
329 double vmin,
double vmax,
double vscl )
override;
330 void Define( wxString &var,
const wxChar *
key, wxString vdefault,
331 wxString vmin, wxString vmax, wxString vscl )
override;
static const AudacityProject::AttachedObjects::RegisteredFactory key
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.
void Define(bool &var, const wxChar *key, bool vdefault, bool vmin, bool vmax, bool vscl) override
SettingsVisitor & Optional(bool &var) override
void DefineEnum(int &var, const wxChar *key, int vdefault, const EnumValueSymbol strings[], size_t nStrings) override
SettingsVisitor & OptionalY(bool &var) override
SettingsVisitor & OptionalN(bool &var) override
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