mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
OldStyleCommandType - It's on the way out.
This renaming makes it clearer which code is still using Dan Horgan's Command system.
This commit is contained in:
parent
2f6fc0a1e5
commit
b83b862b3f
@ -5178,7 +5178,7 @@ void AudacityProject::SafeDisplayStatusMessage(const wxChar *msg)
|
||||
= std::make_unique<CommandOutputTarget>(TargetFactory::ProgressDefault(),
|
||||
std::make_shared<StatusBarTarget>(*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);
|
||||
|
@ -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<ScreenshotCommand> ScreenFrame::CreateCommand()
|
||||
std::make_unique<CommandOutputTarget>(std::make_unique<NullProgressTarget>(),
|
||||
std::make_shared<StatusBarTarget>(*mStatus),
|
||||
std::make_shared<MessageBoxTarget>());
|
||||
//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<ScreenshotCommand>();//*type, std::move(output), this);
|
||||
}
|
||||
|
@ -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)
|
||||
{ }
|
||||
|
||||
|
@ -165,7 +165,7 @@ bool ApplyAndSendResponse::Apply()
|
||||
return result;
|
||||
}
|
||||
|
||||
CommandImplementation::CommandImplementation(CommandType &type)
|
||||
CommandImplementation::CommandImplementation(OldStyleCommandType &type)
|
||||
: mType(type),
|
||||
mParams(type.GetSignature().GetDefaults()),
|
||||
mSetParams()
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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<CommandType> &&type)
|
||||
void CommandDirectory::AddCommand(movable_ptr<OldStyleCommandType> &&type)
|
||||
{
|
||||
wxASSERT(type != NULL);
|
||||
wxString cmdName = type->GetName();
|
||||
|
@ -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<CommandType> &&type);
|
||||
void AddCommand(movable_ptr<OldStyleCommandType> &&type);
|
||||
|
||||
/// Get a pointer to the singleton instance
|
||||
static CommandDirectory *Get();
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <wx/string.h>
|
||||
#include <wx/variant.h>
|
||||
#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<wxString, movable_ptr<Validator>> ValidatorMap;
|
||||
|
||||
// Map from command name to type
|
||||
// to do: use hash
|
||||
typedef std::map<wxString, movable_ptr<CommandType>> CommandMap;
|
||||
typedef std::map<wxString, movable_ptr<OldStyleCommandType>> CommandMap;
|
||||
|
||||
#endif /* End of include guard: __COMMANDMISC__ */
|
||||
|
@ -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 <wx/string.h>
|
||||
|
||||
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();
|
||||
|
@ -41,15 +41,15 @@ class CommandOutputTarget;
|
||||
class CommandSignature;
|
||||
class wxString;
|
||||
|
||||
class CommandType : public AudacityCommand
|
||||
class OldStyleCommandType : public AudacityCommand
|
||||
{
|
||||
private:
|
||||
wxString mName;
|
||||
Maybe<CommandSignature> mSignature;
|
||||
|
||||
public:
|
||||
CommandType();
|
||||
virtual ~CommandType();
|
||||
OldStyleCommandType();
|
||||
virtual ~OldStyleCommandType();
|
||||
wxString GetName() override;
|
||||
CommandSignature &GetSignature();
|
||||
wxString Describe();
|
||||
|
@ -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, () ) \
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user