Audacity 3.2.0
CommandDirectory.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******************************************************************//*******************************************************************/
16
17
18#include "CommandDirectory.h"
19
20std::unique_ptr<CommandDirectory> CommandDirectory::mInstance;
21
23{
24 // Create the command map.
25 // First we have commands which return information
26 //AddCommand(std::make_unique<MessageCommandType>());
27
28// AddCommand(std::make_unique<BatchEvalCommandType>());
29
30
31 // Legacy adapter commands that previously was needed to
32 // access menu items.
33 //AddCommand(std::make_unique<ExecMenuCommandType>());
34
35 // Not needed. Sets selected/solo/mute on multiple tracks.
36 //AddCommand(std::make_unique<SetProjectInfoCommandType>());
37
38// Moved to AudacityCommand
39// AddCommand(std::make_unique<OpenProjectCommandType>());
40// AddCommand(std::make_unique<SaveProjectCommandType>());
41// AddCommand(std::make_unique<ImportCommandType>());
42// AddCommand(std::make_unique<ExportCommandType>());
43// AddCommand(std::make_unique<HelpCommandType>());
44// AddCommand(std::make_unique<GetInfoCommandType>("GetAll"));
45// AddCommand(std::make_unique<GetInfoCommandType>("GetCommands"));
46// AddCommand(std::make_unique<GetInfoCommandType>("GetMenus"));
47// AddCommand(std::make_unique<GetInfoCommandType>("GetMenusPlus"));
48// AddCommand(std::make_unique<GetInfoCommandType>("GetBoxes"));
49// AddCommand(std::make_unique<GetInfoCommandType>("GetClips"));
50
51// AddCommand(std::make_unique<GetTrackInfoCommandType>());
52// AddCommand(std::make_unique<GetProjectInfoCommandType>());
53// AddCommand(std::make_unique<CompareAudioCommandType>());
54// AddCommand(std::make_unique<GetPreferenceCommandType>());
55// AddCommand(std::make_unique<SetPreferenceCommandType>());
56// AddCommand(std::make_unique<ScreenshotCommandType>());
57// AddCommand(std::make_unique<SelectCommandType>());
58// AddCommand(std::make_unique<SetTrackInfoCommandType>());
59
60}
61
63{
64}
65
66OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) const
67{
68 auto iter = sCmdMap().find(cmdName);
69 if (iter == sCmdMap().end())
70 {
71 return nullptr;
72 }
73 return iter->second.get();
74}
75
77{
78 static CommandMap theMap;
79 return theMap;
80}
81
82void CommandDirectory::AddCommand(std::unique_ptr<OldStyleCommandType> type)
83{
84 wxASSERT(type != NULL);
85 // Internal string is shown but only in assertion message
86 auto cmdName = type->GetSymbol().Internal();
87 wxASSERT_MSG(sCmdMap().find(cmdName) == sCmdMap().end()
88 , wxT("A command named ") + cmdName
89 + wxT(" already exists."));
90
91 sCmdMap()[cmdName] = std::move(type);
92}
93
95{
96 if (!mInstance)
98 return mInstance.get();
99}
wxT("CloseDown"))
Contains declarations for CommandDirectory class.
std::map< wxString, std::unique_ptr< OldStyleCommandType > > CommandMap
Definition: CommandMisc.h:36
#define safenew
Definition: MemoryX.h:10
Allows registration and lookup (by name) of command types.
static std::unique_ptr< CommandDirectory > mInstance
static CommandMap & sCmdMap()
static void AddCommand(std::unique_ptr< OldStyleCommandType > type)
OldStyleCommandType * LookUp(const wxString &cmdName) const
static CommandDirectory * Get()
Get a pointer to the singleton instance.
Base class for containing data common to all commands of a given type. Also acts as a factory.
Definition: CommandType.h:45
const char * end(const char *str) noexcept
Definition: StringUtils.h:106