/********************************************************************** Audacity - A Digital Audio Editor Copyright 1999-2009 Audacity Team License: wxWidgets Dan Horgan ******************************************************************//** \file CommandDirectory.cpp \brief A dictionary of supported scripting commands, including functions to look up a command by name. *//*******************************************************************/ #include "../Audacity.h" #include "CommandDirectory.h" std::unique_ptr CommandDirectory::mInstance; CommandDirectory::CommandDirectory() { // Create the command map. // First we have commands which return information //AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // Legacy adapter commands that previously was needed to // access menu items. //AddCommand(std::make_unique()); // Not needed. Sets selected/solo/mute on multiple tracks. //AddCommand(std::make_unique()); // Moved to AudacityCommand // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique("GetAll")); // AddCommand(std::make_unique("GetCommands")); // AddCommand(std::make_unique("GetMenus")); // AddCommand(std::make_unique("GetMenusPlus")); // AddCommand(std::make_unique("GetBoxes")); // AddCommand(std::make_unique("GetClips")); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); // AddCommand(std::make_unique()); } CommandDirectory::~CommandDirectory() { } OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) const { auto iter = sCmdMap().find(cmdName); if (iter == sCmdMap().end()) { return nullptr; } return iter->second.get(); } CommandMap &CommandDirectory::sCmdMap() { static CommandMap theMap; return theMap; } void CommandDirectory::AddCommand(std::unique_ptr type) { wxASSERT(type != NULL); // Internal string is shown but only in assertion message auto cmdName = type->GetSymbol().Internal(); wxASSERT_MSG(sCmdMap().find(cmdName) == sCmdMap().end() , wxT("A command named ") + cmdName + wxT(" already exists.")); sCmdMap()[cmdName] = std::move(type); } CommandDirectory *CommandDirectory::Get() { if (!mInstance) mInstance.reset(safenew CommandDirectory()); return mInstance.get(); }