Audacity  2.2.2
BatchEvalCommand.cpp
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 ******************************************************************//*******************************************************************/
15 
16 #include "../Audacity.h"
17 #include "BatchEvalCommand.h"
18 
20 {
21  return wxT("BatchCommand");
22 }
23 
25 {
26  auto commandNameValidator = make_movable<DefaultValidator>();
27  signature.AddParameter(wxT("CommandName"), wxT(""), std::move(commandNameValidator));
28  auto paramValidator = make_movable<DefaultValidator>();
29  signature.AddParameter(wxT("ParamString"), wxT(""), std::move(paramValidator));
30  auto chainValidator = make_movable<DefaultValidator>();
31  signature.AddParameter(wxT("ChainName"), wxT(""), std::move(chainValidator));
32 }
33 
34 CommandHolder BatchEvalCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
35 {
36  return std::make_shared<BatchEvalCommand>(*this, std::move(target));
37 }
38 
40 {
41 
42  wxString chainName = GetString(wxT("ChainName"));
43  if (chainName != wxT(""))
44  {
45  BatchCommands batch;
46  batch.ReadChain(chainName);
47  return batch.ApplyChain();
48  }
49 
50  wxString cmdName = GetString(wxT("CommandName"));
51  wxString cmdParams = GetString(wxT("ParamString"));
52 
53  // Create a Batch that will have just one command in it...
54  BatchCommands Batch;
55  bool bResult = Batch.ApplyCommand(cmdName, cmdParams);
56  // Relay messages, if any.
57  wxString Message = Batch.GetMessage();
58  if( !Message.IsEmpty() )
59  Status( Message );
60  return bResult;
61 }
62 
64 { }
bool ReadChain(const wxString &chain)
bool ApplyCommand(const wxString &command, const wxString &params)
void BuildSignature(CommandSignature &signature) override
Postcondition: signature is a 'signature' map containing parameter.
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
wxString BuildName() override
CommandHolder Create(std::unique_ptr< CommandOutputTarget > &&target) override
bool Apply(CommandExecutionContext context) override
virtual ~BatchEvalCommand()
void Status(const wxString &status) override
Definition: Command.cpp:179
Maintains the chain of commands used in batch processing. See also BatchCommandDialog and BatchProces...
Definition: BatchCommands.h:22
bool ApplyChain(const wxString &filename=wxT(""))
Represents a context to which a command may be applied.
Definition: Command.h:50
wxString GetMessage()
Definition: BatchCommands.h:69
Class that maps parameter names to default values and validators.