Audacity  2.2.2
Public Member Functions | List of all members
BatchEvalCommand Class Referencefinal

Given a string representing a command, pass it to the MacroCommands system. More...

#include <BatchEvalCommand.h>

Inheritance diagram for BatchEvalCommand:
CommandImplementation OldStyleCommand

Public Member Functions

 BatchEvalCommand (OldStyleCommandType &type)
virtual ~BatchEvalCommand ()
bool Apply (const CommandContext &context) override
- Public Member Functions inherited from CommandImplementation
 CommandImplementation (OldStyleCommandType &type)
virtual ~CommandImplementation ()
wxString GetName ()
 An instance method for getting the command name (for consistency) More...
CommandSignatureGetSignature () override
 Get the signature of the command. More...
bool SetParameter (const wxString &paramName, const wxVariant &paramValue) override
bool Apply () override
bool Apply (const CommandContext &context) override
- Public Member Functions inherited from OldStyleCommand
 OldStyleCommand ()
virtual ~OldStyleCommand ()

Additional Inherited Members

- Protected Member Functions inherited from CommandImplementation
void TypeCheck (const wxString &typeName, const wxString &paramName, const wxVariant &param)
void CheckParam (const wxString &paramName)
bool HasParam (const wxString &paramName)
bool GetBool (const wxString &paramName)
long GetLong (const wxString &paramName)
double GetDouble (const wxString &paramName)
wxString GetString (const wxString &paramName)

Detailed Description

Given a string representing a command, pass it to the MacroCommands system.

Command to make processing of macros available to scripting. It can either make a one command macro, or invoke an existing macro. It will become redundant when menu commands are integrated into scripting.

The eventual aim is to move the code from MacroCommands out into separate command classes, but until this happens, BatchEvalCommand can act as a 'bridge' to that system.

Definition at line 37 of file BatchEvalCommand.h.

Constructor & Destructor Documentation

BatchEvalCommand::BatchEvalCommand ( OldStyleCommandType type)

Definition at line 40 of file BatchEvalCommand.h.

41  : CommandImplementation(type)
42  { }
CommandImplementation(OldStyleCommandType &type)
Definition: Command.cpp:169
BatchEvalCommand::~BatchEvalCommand ( )

Definition at line 72 of file BatchEvalCommand.cpp.

73 { }

Member Function Documentation

bool BatchEvalCommand::Apply ( const CommandContext context)

Implements OldStyleCommand.

Definition at line 40 of file BatchEvalCommand.cpp.

References MacroCommands::ApplyCommand(), MacroCommands::ApplyMacro(), MacroCommandsCatalog::ByCommandId(), MacroCommandsCatalog::end(), MacroCommands::GetMessage(), CommandImplementation::GetString(), CommandContext::project, MacroCommands::ReadMacro(), and CommandContext::Status().

41 {
42  // Uh oh, I need to build a catalog, expensively
43  // Maybe it can be built in one long-lived place and shared among command
44  // objects instead?
45  MacroCommandsCatalog catalog(&context.project);
47  wxString macroName = GetString(wxT("MacroName"));
48  if (macroName != wxT(""))
49  {
50  MacroCommands batch;
51  batch.ReadMacro(macroName);
52  return batch.ApplyMacro(catalog);
53  }
55  wxString cmdName = GetString(wxT("CommandName"));
56  wxString cmdParams = GetString(wxT("ParamString"));
57  auto iter = catalog.ByCommandId(cmdName);
58  const wxString &friendly = (iter == catalog.end())
59  ? cmdName // Expose internal name to user, in default of a better one!
60  : iter->name.Translated();
62  // Create a Batch that will have just one command in it...
63  MacroCommands Batch;
64  bool bResult = Batch.ApplyCommand(friendly, cmdName, cmdParams, &context);
65  // Relay messages, if any.
66  wxString Message = Batch.GetMessage();
67  if( !Message.IsEmpty() )
68  context.Status( Message );
69  return bResult;
70 }
wxString GetString(const wxString &paramName)
Definition: Command.cpp:236
virtual void Status(const wxString &message, bool bFlush=false) const
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename=wxT(""))
Maintains the list of commands for batch/macro processing. See also MacrosWindow and ApplyMacroDialog...
Definition: BatchCommands.h:52
bool ApplyCommand(const wxString &friendlyCommand, const wxString &command, const wxString &params, CommandContext const *pContext=NULL)
bool ReadMacro(const wxString &macro)
AudacityProject & project
wxString GetMessage()

The documentation for this class was generated from the following files: