Audacity 3.2.0
Command.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity - A Digital Audio Editor
4 Copyright 1999-2009 Audacity Team
5 File License: wxWidgets
6
7 Dan Horgan
8
9******************************************************************//*******************************************************************/
16
17#ifndef __COMMAND__
18#define __COMMAND__
19
20#include "CommandSignature.h"
21#include "../commands/AudacityCommand.h"
22
23class AudacityApp;
24class CommandContext;
26
27// Abstract base class for command interface.
28class OldStyleCommand /* not final */
29{
30public:
32
34 virtual ~OldStyleCommand() { }
37 virtual bool SetParameter(const wxString &paramName, const wxVariant &paramValue);
38 virtual bool Apply()=0;
39 virtual bool Apply(const CommandContext &context) = 0;
40};
41
42using OldStyleCommandPointer = std::shared_ptr<OldStyleCommand>;
43
46class DecoratedCommand /* not final */ : public OldStyleCommand
47{
48protected:
50public:
52 : OldStyleCommand{ cmd->mProject }, mCommand(cmd)
53 {
54 wxASSERT(cmd != NULL);
55 }
56 virtual ~DecoratedCommand();
59 bool SetParameter(const wxString &paramName, const wxVariant &paramValue) override;
60};
61
62// Decorator command that performs the given command and then outputs a status
63// message according to the result
65{
66public:
68 const OldStyleCommandPointer &cmd, std::unique_ptr<CommandOutputTargets> &target);
69 bool Apply() override;
70 bool Apply(const CommandContext &context) override;// Error to use this.
71 std::unique_ptr<const CommandContext> mCtx;
72
73};
74
75class AUDACITY_DLL_API CommandImplementation /* not final */
76 : public OldStyleCommand
77{
78private:
82
85 bool Valid(const wxString &paramName, const wxVariant &paramValue);
86
87protected:
88 // Convenience methods for allowing subclasses to access parameters
89 void TypeCheck(const wxString &typeName,
90 const wxString &paramName,
91 const wxVariant &param);
92 void CheckParam(const wxString &paramName);
93 bool HasParam( const wxString &paramName);
94 bool GetBool(const wxString &paramName);
95 long GetLong(const wxString &paramName);
96 double GetDouble(const wxString &paramName);
97 wxString GetString(const wxString &paramName);
98
99public:
103
104 virtual ~CommandImplementation();
105
108
110 CommandSignature &GetSignature() override;
111
114 bool SetParameter(const wxString &paramName, const wxVariant &paramValue) override;
115
116 // Subclasses should override the following:
117 // =========================================
118
121 bool Apply() override { return false;};// No longer supported.
122 bool Apply(const CommandContext &context) override;
123};
124
125#endif /* End of include guard: __COMMAND__ */
std::map< wxString, wxVariant > ParamValueMap
Definition: CommandMisc.h:23
std::map< wxString, bool > ParamBoolMap
Definition: CommandMisc.h:28
Declaration of CommandSignature class.
const auto project
ApplyAndSendResponse is a DecoratoredCommand that performs the given command and then outputs a statu...
Definition: Command.h:65
bool Apply(const CommandContext &context) override
ApplyAndSendResponse(const OldStyleCommandPointer &cmd, std::unique_ptr< CommandOutputTargets > &target)
Definition: Command.cpp:122
bool Apply() override
Definition: Command.cpp:137
std::unique_ptr< const CommandContext > mCtx
Definition: Command.h:71
AudacityApp is the 'main' class for Audacity.
Definition: AudacityApp.h:41
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
is derived from OldStyleCommand. It validates and applies the command. CommandImplementation::Apply()...
Definition: Command.h:77
bool Apply() override
Definition: Command.h:121
ParamValueMap mParams
Definition: Command.h:80
OldStyleCommandType & mType
Definition: Command.h:79
ParamBoolMap mSetParams
Definition: Command.h:81
bool Valid(const wxString &paramName, const wxVariant &paramValue)
bool Apply(const CommandContext &context) override
CommandOutputTargets a mix of three output classes to output progress indication, status messages and...
Class that maps parameter names to default values and validators.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
DecoratedCommand is a decorator for command. It forwards functions to the mCommand it holds.
Definition: Command.h:47
CommandSignature & GetSignature() override
Definition: Command.cpp:111
OldStyleCommandPointer mCommand
Definition: Command.h:49
virtual ~DecoratedCommand()
Definition: Command.cpp:102
bool SetParameter(const wxString &paramName, const wxVariant &paramValue) override
Definition: Command.cpp:116
DecoratedCommand(const OldStyleCommandPointer &cmd)
Definition: Command.h:51
ComponentInterfaceSymbol GetSymbol() override
Definition: Command.cpp:106
Abstract base class for command interface. This is the version created by Dan Horgan....
Definition: Command.h:29
OldStyleCommand(AudacityProject &project)
Definition: Command.h:33
virtual bool SetParameter(const wxString &paramName, const wxVariant &paramValue)
Definition: Command.cpp:95
virtual ~OldStyleCommand()
Definition: Command.h:34
virtual CommandSignature & GetSignature()=0
virtual bool Apply()=0
AudacityProject & mProject
Definition: Command.h:31
virtual bool Apply(const CommandContext &context)=0
virtual ComponentInterfaceSymbol GetSymbol()=0
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.
Definition: CommandType.h:45