Audacity  2.2.2
HelpCommand.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity - A Digital Audio Editor
4  Copyright 1999-2009 Audacity Team
5  License: wxwidgets
6 
7  Dan Horgan
8 
9 ******************************************************************//*******************************************************************/
15 
16 #include "../Audacity.h"
17 #include "HelpCommand.h"
18 #include "CommandDirectory.h"
19 #include <wx/string.h>
20 
22 {
23  return wxT("Help");
24 }
25 
27 {
28  auto commandNameValidator = make_movable<DefaultValidator>();
29  signature.AddParameter(wxT("CommandName"), wxT("Help"), std::move(commandNameValidator));
30 }
31 
32 CommandHolder HelpCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
33 {
34  return std::make_shared<HelpCommand>(*this, std::move(target));
35 }
36 
38 {
39  wxString commandName = GetString(wxT("CommandName"));
40  CommandType *type = CommandDirectory::Get()->LookUp(commandName);
41  if (type == NULL)
42  {
43  Error(wxString::Format(wxT("Command '%s' does not exist!"), commandName));
44  return false;
45  }
46  Status(type->Describe());
47  return true;
48 }
static CommandDirectory * Get()
Get a pointer to the singleton instance.
std::shared_ptr< Command > CommandHolder
void AddParameter(const wxString &name, const wxVariant &dft, movable_ptr< Validator > &&valid)
wxString GetString(const wxString &paramName)
Definition: Command.cpp:165
bool Apply(CommandExecutionContext context) override
Definition: HelpCommand.cpp:37
wxString BuildName() override
Definition: HelpCommand.cpp:21
Contains declarations for CommandDirectory class.
CommandType * LookUp(const wxString &cmdName) const
CommandHolder Create(std::unique_ptr< CommandOutputTarget > &&target) override
Definition: HelpCommand.cpp:32
Base class for containing data common to all commands of a given type. Also acts as a factory...
Definition: CommandType.h:29
void Status(const wxString &status) override
Definition: Command.cpp:179
Represents a context to which a command may be applied.
Definition: Command.h:50
wxString Describe()
Definition: CommandType.cpp:51
Class that maps parameter names to default values and validators.
void BuildSignature(CommandSignature &signature) override
Postcondition: signature is a 'signature' map containing parameter.
Definition: HelpCommand.cpp:26
void Error(const wxString &message) override
Definition: Command.cpp:184