Audacity  3.0.3
BatchCommands.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  MacroCommands.h
6 
7  Dominic Mazzoni
8  James Crook
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_BATCH_COMMANDS_DIALOG__
13 #define __AUDACITY_BATCH_COMMANDS_DIALOG__
14 
15 #include <wx/defs.h>
16 
17 #include "export/Export.h"
18 #include "commands/CommandFlag.h"
19 #include "ComponentInterface.h" // for ComponentInterfaceSymbol
20 
21 class wxArrayString;
22 class Effect;
23 class CommandContext;
24 class CommandManager;
25 class AudacityProject;
26 class wxArrayStringEx;
27 
29 public:
30  // A triple of user-visible name, internal string identifier and type/help string.
31  struct Entry {
34  };
35  using Entries = std::vector<Entry>;
36 
37  MacroCommandsCatalog( const AudacityProject *project );
38 
39  // binary search
40  Entries::const_iterator ByFriendlyName( const TranslatableString &friendlyName ) const;
41  // linear search
42  Entries::const_iterator ByCommandId( const CommandID &commandId ) const;
43 
44  // Lookup by position as sorted by friendly name
45  const Entry &operator[] ( size_t index ) const { return mCommands[index]; }
46 
47  Entries::const_iterator begin() const { return mCommands.begin(); }
48  Entries::const_iterator end() const { return mCommands.end(); }
49 
50 private:
51  // Sorted by friendly name
53 };
54 
55 // Stores information for one macro
56 class MacroCommands final {
57  public:
58  static bool DoAudacityCommand(
59  const PluginID & ID, const CommandContext & context, unsigned flags );
60 
61  // constructors and destructors
62  MacroCommands( AudacityProject &project );
63  public:
64  bool ApplyMacro( const MacroCommandsCatalog &catalog,
65  const wxString & filename = {});
66  static bool HandleTextualCommand( CommandManager &commandManager,
67  const CommandID & Str,
68  const CommandContext & context, CommandFlag flags, bool alwaysEnabled);
69  bool ApplyCommand( const TranslatableString &friendlyCommand,
70  const CommandID & command, const wxString & params,
71  CommandContext const * pContext=NULL );
72  bool ApplyCommandInBatchMode( const TranslatableString &friendlyCommand,
73  const CommandID & command, const wxString &params,
74  CommandContext const * pContext = NULL);
75  bool ApplyEffectCommand(
76  const PluginID & ID, const TranslatableString &friendlyCommand,
77  const CommandID & command,
78  const wxString & params, const CommandContext & Context);
79  bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params );
80  void AbortBatch();
81 
82  // These commands do not depend on the command list.
83  static void MigrateLegacyChains();
84  static wxArrayString GetNames();
86 
87  static wxString GetCurrentParamsFor(const CommandID & command);
88  static wxString PromptForParamsFor(
89  const CommandID & command, const wxString & params, wxWindow &parent);
90  static wxString PromptForPresetFor(const CommandID & command, const wxString & params, wxWindow *parent);
91 
92  // These commands do depend on the command list.
93  void ResetMacro();
94 
95  void RestoreMacro(const wxString & name);
96  wxString ReadMacro(const wxString & macro, wxWindow *parent = nullptr);
97  wxString WriteMacro(const wxString & macro, wxWindow *parent = nullptr);
98  bool AddMacro(const wxString & macro);
99  bool DeleteMacro(const wxString & name);
100  bool RenameMacro(const wxString & oldmacro, const wxString & newmacro);
101 
102  void AddToMacro(const CommandID & command, int before = -1);
103  void AddToMacro(const CommandID & command, const wxString & params, int before = -1);
104 
105  void DeleteFromMacro(int index);
106  CommandID GetCommand(int index);
107  wxString GetParams(int index);
108  int GetCount();
109  wxString GetMessage(){ return mMessage;};
110  void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;};
111 
112  bool IsFixed(const wxString & name);
113 
114  void Split(const wxString & str, wxString & command, wxString & param);
115  wxString Join(const wxString & command, const wxString & param);
116 
117 private:
119 
121  wxArrayString mParamsMacro;
122  bool mAbort;
123  wxString mMessage;
124 
126  wxString mFileName;
127 };
128 
129 #endif
MacroCommands::Split
void Split(const wxString &str, wxString &command, wxString &param)
Definition: BatchCommands.cpp:939
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
MacroCommandsCatalog::Entry
Definition: BatchCommands.h:31
MacroCommands::RestoreMacro
void RestoreMacro(const wxString &name)
Definition: BatchCommands.cpp:84
str
#define str(a)
Definition: DBConnection.cpp:30
Effect
An Effect object is at once host and client: it is self-hosting.
Definition: Effect.h:76
MacroCommands::GetCurrentParamsFor
static wxString GetCurrentParamsFor(const CommandID &command)
Definition: BatchCommands.cpp:435
MacroCommands::PromptForPresetFor
static wxString PromptForPresetFor(const CommandID &command, const wxString &params, wxWindow *parent)
Definition: BatchCommands.cpp:472
MacroCommandsCatalog::end
Entries::const_iterator end() const
Definition: BatchCommands.h:48
MacroCommandsCatalog::mCommands
Entries mCommands
Definition: BatchCommands.h:52
Exporter
Definition: Export.h:166
MacroCommands::ReportAndSkip
bool ReportAndSkip(const TranslatableString &friendlyCommand, const wxString &params)
Definition: BatchCommands.cpp:853
MacroCommands::ReadMacro
wxString ReadMacro(const wxString &macro, wxWindow *parent=nullptr)
Definition: BatchCommands.cpp:124
MacroCommands::ApplyEffectCommand
bool ApplyEffectCommand(const PluginID &ID, const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, const CommandContext &Context)
Definition: BatchCommands.cpp:536
MacroCommands::ApplyMacro
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename={})
Definition: BatchCommands.cpp:688
MacroCommands::mCommandMacro
CommandIDs mCommandMacro
Definition: BatchCommands.h:120
MacroCommandsCatalog::ByCommandId
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Definition: BatchCommands.cpp:426
MacroCommands::RenameMacro
bool RenameMacro(const wxString &oldmacro, const wxString &newmacro)
Definition: BatchCommands.cpp:292
MacroCommands::Join
wxString Join(const wxString &command, const wxString &param)
Definition: BatchCommands.cpp:961
MacroCommands::mFileName
wxString mFileName
Definition: BatchCommands.h:126
MacroCommands::MacroCommands
MacroCommands(AudacityProject &project)
Definition: BatchCommands.cpp:54
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
MacroCommands::mMessage
wxString mMessage
Definition: BatchCommands.h:123
MacroCommands::AddToMacro
void AddToMacro(const CommandID &command, int before=-1)
Definition: BatchCommands.cpp:820
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
MacroCommands::AbortBatch
void AbortBatch()
Definition: BatchCommands.cpp:815
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
MacroCommands::MigrateLegacyChains
static void MigrateLegacyChains()
Definition: BatchCommands.cpp:878
MacroCommandsCatalog::Entries
std::vector< Entry > Entries
Definition: BatchCommands.h:35
MacroCommandsCatalog
Definition: BatchCommands.h:28
CommandIDs
std::vector< CommandID > CommandIDs
Definition: Identifier.h:233
MacroCommandsCatalog::Entry::category
TranslatableString category
Definition: BatchCommands.h:33
MacroCommands::GetCount
int GetCount()
Definition: BatchCommands.cpp:119
MacroCommands::DoAudacityCommand
static bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
Definition: BatchCommands.cpp:497
ComponentInterface.h
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:34
MacroCommands::GetCommand
CommandID GetCommand(int index)
Definition: BatchCommands.cpp:101
MacroCommands
Maintains the list of commands for batch/macro processing. See also MacrosWindow and ApplyMacroDialog...
Definition: BatchCommands.h:56
PluginID
wxString PluginID
Definition: EffectManager.h:31
name
const TranslatableString name
Definition: Distortion.cpp:98
Export.h
MacroCommands::DeleteFromMacro
void DeleteFromMacro(int index)
Definition: BatchCommands.cpp:835
MacroCommands::GetParams
wxString GetParams(int index)
Definition: BatchCommands.cpp:110
MacroCommands::mProject
AudacityProject & mProject
Definition: BatchCommands.h:118
MacroCommands::GetNames
static wxArrayString GetNames()
Definition: BatchCommands.cpp:911
MacroCommands::DeleteMacro
bool DeleteMacro(const wxString &name)
Definition: BatchCommands.cpp:277
MacroCommands::WriteMacro
wxString WriteMacro(const wxString &macro, wxWindow *parent=nullptr)
Definition: BatchCommands.cpp:206
MacroCommands::AddMacro
bool AddMacro(const wxString &macro)
Definition: BatchCommands.cpp:265
MacroCommands::HandleTextualCommand
static bool HandleTextualCommand(CommandManager &commandManager, const CommandID &Str, const CommandContext &context, CommandFlag flags, bool alwaysEnabled)
Definition: BatchCommands.cpp:593
TaggedIdentifier< CommandIdTag, false >
MacroCommands::PromptForParamsFor
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, wxWindow &parent)
Definition: BatchCommands.cpp:447
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
MacroCommandsCatalog::ByFriendlyName
Entries::const_iterator ByFriendlyName(const TranslatableString &friendlyName) const
Definition: BatchCommands.cpp:407
MacroCommandsCatalog::begin
Entries::const_iterator begin() const
Definition: BatchCommands.h:47
MacroCommandsCatalog::MacroCommandsCatalog
MacroCommandsCatalog(const AudacityProject *project)
Definition: BatchCommands.cpp:303
MacroCommands::mExporter
Exporter mExporter
Definition: BatchCommands.h:125
MacroCommandsCatalog::Entry::name
ComponentInterfaceSymbol name
Definition: BatchCommands.h:32
CommandManager
CommandManager implements a system for organizing all user-callable commands.
Definition: CommandManager.h:59
MacroCommands::AddToMessage
void AddToMessage(const wxString &msgIn)
Definition: BatchCommands.h:110
MacroCommands::ResetMacro
void ResetMacro()
Definition: BatchCommands.cpp:845
MacroCommands::GetMessage
wxString GetMessage()
Definition: BatchCommands.h:109
MacroCommands::GetNamesOfDefaultMacros
static wxArrayStringEx GetNamesOfDefaultMacros()
Definition: BatchCommands.cpp:76
MacroCommandsCatalog::operator[]
const Entry & operator[](size_t index) const
Definition: BatchCommands.h:45
params
EffectDistortion::Params params
Definition: Distortion.cpp:99
MacroCommands::mParamsMacro
wxArrayString mParamsMacro
Definition: BatchCommands.h:121
MacroCommands::ApplyCommandInBatchMode
bool ApplyCommandInBatchMode(const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, CommandContext const *pContext=NULL)
Definition: BatchCommands.cpp:663
MacroCommands::ApplyCommand
bool ApplyCommand(const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, CommandContext const *pContext=NULL)
Definition: BatchCommands.cpp:621
MacroCommands::mAbort
bool mAbort
Definition: BatchCommands.h:122
CommandFlag.h
MacroCommands::IsFixed
bool IsFixed(const wxString &name)
Definition: BatchCommands.cpp:931