From 3017f8dddf52d7de2296dde9a70c07e02223071c Mon Sep 17 00:00:00 2001 From: James Crook Date: Wed, 7 Feb 2018 21:50:55 +0000 Subject: [PATCH] OldStyleCommandType - It's on the way out. This renaming makes it clearer which code is still using Dan Horgan's Command system. --- src/Project.cpp | 2 +- src/Screenshot.cpp | 4 ++-- src/commands/BatchEvalCommand.h | 4 ++-- src/commands/Command.cpp | 2 +- src/commands/Command.h | 4 ++-- src/commands/CommandBuilder.cpp | 4 ++-- src/commands/CommandDirectory.cpp | 4 ++-- src/commands/CommandDirectory.h | 4 ++-- src/commands/CommandMisc.h | 4 ++-- src/commands/CommandType.cpp | 12 ++++++------ src/commands/CommandType.h | 6 +++--- src/commands/LoadCommands.cpp | 2 +- src/commands/MessageCommand.h | 4 ++-- src/commands/ScreenshotCommand.cpp | 4 ++-- src/commands/ScreenshotCommand.h | 5 +---- 15 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index d79a48ecb..96dedf049 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -5175,7 +5175,7 @@ void AudacityProject::SafeDisplayStatusMessage(const wxChar *msg) = std::make_unique(TargetFactory::ProgressDefault(), std::make_shared(*mStatusBar), TargetFactory::MessageDefault()); - CommandType *type = CommandDirectory::Get()->LookUp(wxT("Message")); + OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("Message")); wxASSERT_MSG(type != NULL, wxT("Message command not found!")); OldStyleCommandPointer statusCmd = type->Create(std::move(target)); statusCmd->SetParameter(wxT("MessageString"), msg); diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index ca4edb7cd..369526378 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -47,7 +47,7 @@ It forwards the actual work of doing the commands to the ScreenshotCommand. #include "Track.h" -class CommandType; +class OldStyleCommandType; //////////////////////////////////////////////////////////////////////////////// @@ -251,7 +251,7 @@ std::unique_ptr ScreenFrame::CreateCommand() std::make_unique(std::make_unique(), std::make_shared(*mStatus), std::make_shared()); - //CommandType *type = CommandDirectory::Get()->LookUp(wxT("Screenshot")); + //OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("Screenshot")); //wxASSERT_MSG(type != NULL, wxT("Screenshot command doesn't exist!")); return std::make_unique();//*type, std::move(output), this); } diff --git a/src/commands/BatchEvalCommand.h b/src/commands/BatchEvalCommand.h index 8fb3e8f3e..db5d2a803 100644 --- a/src/commands/BatchEvalCommand.h +++ b/src/commands/BatchEvalCommand.h @@ -26,7 +26,7 @@ to that system. #include "CommandType.h" #include "../BatchCommands.h" -class BatchEvalCommandType final : public CommandType +class BatchEvalCommandType final : public OldStyleCommandType { public: wxString BuildName() override; @@ -37,7 +37,7 @@ public: class BatchEvalCommand final : public CommandImplementation { public: - BatchEvalCommand(CommandType &type) + BatchEvalCommand(OldStyleCommandType &type) : CommandImplementation(type) { } diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index a5327cfc2..d0bb2670d 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -165,7 +165,7 @@ bool ApplyAndSendResponse::Apply() return result; } -CommandImplementation::CommandImplementation(CommandType &type) +CommandImplementation::CommandImplementation(OldStyleCommandType &type) : mType(type), mParams(type.GetSignature().GetDefaults()), mSetParams() diff --git a/src/commands/Command.h b/src/commands/Command.h index f58b5382b..34b41f84e 100644 --- a/src/commands/Command.h +++ b/src/commands/Command.h @@ -77,7 +77,7 @@ public: class CommandImplementation /* not final */ : public OldStyleCommand { private: - CommandType &mType; + OldStyleCommandType &mType; ParamValueMap mParams; ParamBoolMap mSetParams; @@ -100,7 +100,7 @@ protected: public: /// Constructor should not be called directly; only by a factory which /// ensures name and params are set appropriately for the command. - CommandImplementation(CommandType &type); + CommandImplementation(OldStyleCommandType &type); virtual ~CommandImplementation(); diff --git a/src/commands/CommandBuilder.cpp b/src/commands/CommandBuilder.cpp index 12d27a3a7..d0443762a 100644 --- a/src/commands/CommandBuilder.cpp +++ b/src/commands/CommandBuilder.cpp @@ -90,13 +90,13 @@ void CommandBuilder::BuildCommand(const wxString &cmdName, scriptOutput); #ifdef OLD_BATCH_SYSTEM - CommandType *factory = CommandDirectory::Get()->LookUp(cmdName); + OldStyleCommandType *factory = CommandDirectory::Get()->LookUp(cmdName); if (factory == NULL) { // Fall back to hoping the Batch Command system can handle it #endif - CommandType *type = CommandDirectory::Get()->LookUp(wxT("BatchCommand")); + OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("BatchCommand")); wxASSERT(type != NULL); mCommand = type->Create(nullptr); mCommand->SetParameter(wxT("CommandName"), cmdName); diff --git a/src/commands/CommandDirectory.cpp b/src/commands/CommandDirectory.cpp index 1893c35e4..db94c3841 100644 --- a/src/commands/CommandDirectory.cpp +++ b/src/commands/CommandDirectory.cpp @@ -67,7 +67,7 @@ CommandDirectory::~CommandDirectory() { } -CommandType *CommandDirectory::LookUp(const wxString &cmdName) const +OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) const { CommandMap::const_iterator iter = mCmdMap.find(cmdName); if (iter == mCmdMap.end()) @@ -77,7 +77,7 @@ CommandType *CommandDirectory::LookUp(const wxString &cmdName) const return iter->second.get(); } -void CommandDirectory::AddCommand(movable_ptr &&type) +void CommandDirectory::AddCommand(movable_ptr &&type) { wxASSERT(type != NULL); wxString cmdName = type->GetName(); diff --git a/src/commands/CommandDirectory.h b/src/commands/CommandDirectory.h index 5615fa400..34a47599e 100644 --- a/src/commands/CommandDirectory.h +++ b/src/commands/CommandDirectory.h @@ -41,10 +41,10 @@ public: /// If a command with the given name has been registered in the directory, /// return a pointer to the factory for commands of that type. /// Otherwise return NULL. - CommandType *LookUp(const wxString &cmdName) const; + OldStyleCommandType *LookUp(const wxString &cmdName) const; /// Register a type of command with the directory. - void AddCommand(movable_ptr &&type); + void AddCommand(movable_ptr &&type); /// Get a pointer to the singleton instance static CommandDirectory *Get(); diff --git a/src/commands/CommandMisc.h b/src/commands/CommandMisc.h index de438301d..4f384deb4 100644 --- a/src/commands/CommandMisc.h +++ b/src/commands/CommandMisc.h @@ -20,7 +20,7 @@ #include #include #include "Validators.h" -class CommandType; +class OldStyleCommandType; // Map from parameter name to the value of the parameter // to do: use hash @@ -33,6 +33,6 @@ typedef std::map> ValidatorMap; // Map from command name to type // to do: use hash -typedef std::map> CommandMap; +typedef std::map> CommandMap; #endif /* End of include guard: __COMMANDMISC__ */ diff --git a/src/commands/CommandType.cpp b/src/commands/CommandType.cpp index 61bc6b128..a26af3466 100644 --- a/src/commands/CommandType.cpp +++ b/src/commands/CommandType.cpp @@ -11,7 +11,7 @@ \file CommandType.cpp \brief Contains definitions for CommandType class -\class CommandType +\class OldStyleCommandType \brief Base class for containing data common to all commands of a given type. Also acts as a factory. @@ -23,22 +23,22 @@ Also acts as a factory. #include "CommandSignature.h" #include -CommandType::CommandType() +OldStyleCommandType::OldStyleCommandType() : mName{}, mSignature{} { } -CommandType::~CommandType() +OldStyleCommandType::~OldStyleCommandType() { } -wxString CommandType::GetName() +wxString OldStyleCommandType::GetName() { if (mName.empty()) mName = BuildName(); return mName; } -CommandSignature &CommandType::GetSignature() +CommandSignature &OldStyleCommandType::GetSignature() { if (!mSignature) { @@ -48,7 +48,7 @@ CommandSignature &CommandType::GetSignature() return *mSignature; } -wxString CommandType::Describe() +wxString OldStyleCommandType::Describe() { wxString desc = GetName() + wxT("\nParameters:"); GetSignature(); diff --git a/src/commands/CommandType.h b/src/commands/CommandType.h index 964d440d3..50c69ca52 100644 --- a/src/commands/CommandType.h +++ b/src/commands/CommandType.h @@ -41,15 +41,15 @@ class CommandOutputTarget; class CommandSignature; class wxString; -class CommandType : public AudacityCommand +class OldStyleCommandType : public AudacityCommand { private: wxString mName; Maybe mSignature; public: - CommandType(); - virtual ~CommandType(); + OldStyleCommandType(); + virtual ~OldStyleCommandType(); wxString GetName() override; CommandSignature &GetSignature(); wxString Describe(); diff --git a/src/commands/LoadCommands.cpp b/src/commands/LoadCommands.cpp index 1b5bbccff..8d1e70289 100644 --- a/src/commands/LoadCommands.cpp +++ b/src/commands/LoadCommands.cpp @@ -38,7 +38,7 @@ modelled on BuiltinEffectsModule // #define COMMAND_LIST \ COMMAND( DEMO, DemoCommand, () ) \ - COMMAND( SCREENSHOT, ScreenshotCommandType, () ) \ + COMMAND( SCREENSHOT, ScreenshotCommand, () ) \ COMMAND( COMPARE_AUDIO, CompareAudioCommand, () ) \ COMMAND( GET_TRACK_INFO, GetTrackInfoCommand, () ) \ COMMAND( SET_TRACK_INFO, SetTrackInfoCommand, () ) \ diff --git a/src/commands/MessageCommand.h b/src/commands/MessageCommand.h index 240ecb05b..9f5d75530 100644 --- a/src/commands/MessageCommand.h +++ b/src/commands/MessageCommand.h @@ -24,7 +24,7 @@ #include "Command.h" #include "CommandType.h" -class MessageCommandType final : public CommandType +class MessageCommandType final : public OldStyleCommandType { public: wxString BuildName() override; @@ -35,7 +35,7 @@ public: class MessageCommand final : public CommandImplementation { public: - MessageCommand(CommandType &type) + MessageCommand(OldStyleCommandType &type) : CommandImplementation(type) {} bool Apply(const CommandContext &context ) override; }; diff --git a/src/commands/ScreenshotCommand.cpp b/src/commands/ScreenshotCommand.cpp index 4233ae7a4..c5bccc936 100644 --- a/src/commands/ScreenshotCommand.cpp +++ b/src/commands/ScreenshotCommand.cpp @@ -122,7 +122,7 @@ static const wxString kBackgroundStrings[kNumBackgrounds] = }; -bool ScreenshotCommandType::DefineParams( ShuttleParams & S ){ +bool ScreenshotCommand::DefineParams( ShuttleParams & S ){ wxArrayString whats(kNumCaptureWhats, kCaptureWhatStrings); wxArrayString backs(kNumBackgrounds, kBackgroundStrings); S.Define( mPath, wxT("Path"), wxT(""), wxT(""), wxT(""), wxT("")); @@ -131,7 +131,7 @@ bool ScreenshotCommandType::DefineParams( ShuttleParams & S ){ return true; }; -void ScreenshotCommandType::PopulateOrExchange(ShuttleGui & S) +void ScreenshotCommand::PopulateOrExchange(ShuttleGui & S) { wxArrayString whats(kNumCaptureWhats, kCaptureWhatStrings); wxArrayString backs(kNumBackgrounds, kBackgroundStrings); diff --git a/src/commands/ScreenshotCommand.h b/src/commands/ScreenshotCommand.h index f86f1c9cf..64cdca5dd 100644 --- a/src/commands/ScreenshotCommand.h +++ b/src/commands/ScreenshotCommand.h @@ -30,7 +30,7 @@ class CommandContext; #define SCREENSHOT_PLUGIN_SYMBOL XO("Screenshot") -class ScreenshotCommandType : public AudacityCommand +class ScreenshotCommand : public AudacityCommand { public: // CommandDefinitionInterface overrides @@ -48,10 +48,7 @@ private: wxString mPath; friend class ScreenshotCommand; friend class ScreenFrame; -}; -class ScreenshotCommand final : public ScreenshotCommandType -{ public: bool Apply(const CommandContext & context) override; void GetDerivedParams();