83#include <wx/variant.h>
96 const wxVariant & WXUNUSED(paramValue))
98 wxASSERT_MSG(
false,
wxT(
"Tried to set parameter for command which doesn't support parameters!"));
117 const wxVariant ¶mValue)
119 return mCommand->SetParameter(paramName, paramValue);
132 wxLogMessage(
"Context was passed in, but was ignored. ApplyAndSendResponse has its own one");
145 auto result = GuardedCall<bool>(
150 wxString response =
wxT(
"\n" );
158 response +=
wxT(
" finished: ");
161 response +=
wxT(
"OK");
165 response +=
wxT(
"Failed!");
167 mCtx->Status(response,
true);
175 mParams(type.GetSignature().GetDefaults()),
185 const wxString ¶mName,
186 const wxVariant ¶m)
189 wxASSERT_MSG(param.IsType(typeName),
191 +
wxT(
"command tried to get '")
193 +
wxT(
"' parameter as a ")
195 +
wxT(
", but that wasn't enforced by the command signature."));
203 +
wxT(
"command tried to get '")
205 +
wxT(
"' parameter, but that parameter doesn't exist in the command signature!"));
211 if(
mParams.count(paramName) < 1)
219 const wxVariant &v =
mParams[paramName];
227 const wxVariant &v =
mParams[paramName];
229 return (
long)v.GetDouble();
235 const wxVariant &v =
mParams[paramName];
237 return v.GetDouble();
243 const wxVariant &v =
mParams[paramName];
245 return v.GetString();
262 wxASSERT(!paramValue.IsType(
wxT(
"null")));
264 ParamValueMap::iterator iter =
mParams.find(paramName);
269 context.
Error( wxString::Format(
270 _(
"%s is not a parameter accepted by %s"),
277 if (!validator.
Validate(paramValue))
279 context.
Error( wxString::Format(
280 _(
"Invalid value for parameter '%s': should be %s"),
Declare abstract class AudacityException, some often-used subclasses, and GuardedCall.
@ Internal
Indicates internal failure from Audacity.
Contains declaration of Command base class.
Contains declarations for CommandDirectory class.
ApplyAndSendResponse(const OldStyleCommandPointer &cmd, std::unique_ptr< CommandOutputTargets > &target)
std::unique_ptr< const CommandContext > mCtx
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
virtual void Error(const wxString &message) const
bool GetBool(const wxString ¶mName)
CommandSignature & GetSignature() override
Get the signature of the command.
bool HasParam(const wxString ¶mName)
ComponentInterfaceSymbol GetSymbol() override
An instance method for getting the command name (for consistency)
bool SetParameter(const wxString ¶mName, const wxVariant ¶mValue) override
void CheckParam(const wxString ¶mName)
virtual ~CommandImplementation()
OldStyleCommandType & mType
void TypeCheck(const wxString &typeName, const wxString ¶mName, const wxVariant ¶m)
long GetLong(const wxString ¶mName)
CommandImplementation(AudacityProject &project, OldStyleCommandType &type)
wxString GetString(const wxString ¶mName)
double GetDouble(const wxString ¶mName)
Class that maps parameter names to default values and validators.
Validator & GetValidator(const wxString ¶mName)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
const wxString & Internal() const
DecoratedCommand is a decorator for command. It forwards functions to the mCommand it holds.
CommandSignature & GetSignature() override
OldStyleCommandPointer mCommand
virtual ~DecoratedCommand()
bool SetParameter(const wxString ¶mName, const wxVariant ¶mValue) override
ComponentInterfaceSymbol GetSymbol() override
Abstract base class for command interface. This is the version created by Dan Horgan....
virtual bool SetParameter(const wxString ¶mName, const wxVariant ¶mValue)
AudacityProject & mProject
OldStyleCommandPointer is a unique_ptr to an OldStyleCommand.
Base class for containing data common to all commands of a given type. Also acts as a factory.
CommandSignature & GetSignature()
ComponentInterfaceSymbol GetSymbol() const override
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
virtual wxString GetDescription() const
const wxVariant & GetConverted()
virtual bool Validate(const wxVariant &v)
Judge whether the passed value satisfies the Validator.