Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
CommandDirectory Class Reference

Allows registration and lookup (by name) of command types. More...

#include <CommandDirectory.h>

Collaboration diagram for CommandDirectory:
[legend]

Classes

struct  RegisterType
 

Public Member Functions

 ~CommandDirectory ()
 
OldStyleCommandTypeLookUp (const wxString &cmdName) const
 

Static Public Member Functions

static CommandDirectoryGet ()
 Get a pointer to the singleton instance. More...
 

Private Member Functions

 CommandDirectory ()
 

Static Private Member Functions

static CommandMapsCmdMap ()
 
static void AddCommand (std::unique_ptr< OldStyleCommandType > type)
 

Static Private Attributes

static std::unique_ptr< CommandDirectorymInstance
 

Detailed Description

Allows registration and lookup (by name) of command types.

A singleton. This fulfills a similar purpose to CommandManager, but for general Commands rather than menu items. Eventually they could be unified but for now they are kept separate to make things simpler.

Definition at line 30 of file CommandDirectory.h.

Constructor & Destructor Documentation

◆ ~CommandDirectory()

CommandDirectory::~CommandDirectory ( )

Definition at line 62 of file CommandDirectory.cpp.

63{
64}

◆ CommandDirectory()

CommandDirectory::CommandDirectory ( )
private

Definition at line 22 of file CommandDirectory.cpp.

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}

Referenced by Get().

Here is the caller graph for this function:

Member Function Documentation

◆ AddCommand()

void CommandDirectory::AddCommand ( std::unique_ptr< OldStyleCommandType type)
staticprivate

Definition at line 82 of file CommandDirectory.cpp.

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}
wxT("CloseDown"))
static CommandMap & sCmdMap()
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), sCmdMap(), and wxT().

Here is the call graph for this function:

◆ Get()

CommandDirectory * CommandDirectory::Get ( )
static

Get a pointer to the singleton instance.

Definition at line 94 of file CommandDirectory.cpp.

95{
96 if (!mInstance)
98 return mInstance.get();
99}
#define safenew
Definition: MemoryX.h:9
static std::unique_ptr< CommandDirectory > mInstance

References CommandDirectory(), mInstance, and safenew.

Referenced by CommandBuilder::BuildCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LookUp()

OldStyleCommandType * CommandDirectory::LookUp ( const wxString &  cmdName) const

If a command with the given name has been registered in the directory, return a pointer to the factory for commands of that type. Otherwise return NULL.

Definition at line 66 of file CommandDirectory.cpp.

67{
68 auto iter = sCmdMap().find(cmdName);
69 if (iter == sCmdMap().end())
70 {
71 return nullptr;
72 }
73 return iter->second.get();
74}

References details::end(), and sCmdMap().

Referenced by CommandBuilder::BuildCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sCmdMap()

CommandMap & CommandDirectory::sCmdMap ( )
staticprivate

Definition at line 76 of file CommandDirectory.cpp.

77{
78 static CommandMap theMap;
79 return theMap;
80}
std::map< wxString, std::unique_ptr< OldStyleCommandType > > CommandMap
Definition: CommandMisc.h:36

Referenced by AddCommand(), and LookUp().

Here is the caller graph for this function:

Member Data Documentation

◆ mInstance

std::unique_ptr< CommandDirectory > CommandDirectory::mInstance
staticprivate

Definition at line 33 of file CommandDirectory.h.

Referenced by Get().


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