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