From 443938e5ea8dbf83e6f4076c2ea4cb3abb281dca Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 10 Aug 2024 21:32:45 -0400 Subject: [PATCH] add CommandManager --- src/app/editor/system/command_manager.h | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/app/editor/system/command_manager.h diff --git a/src/app/editor/system/command_manager.h b/src/app/editor/system/command_manager.h new file mode 100644 index 00000000..4a36397b --- /dev/null +++ b/src/app/editor/system/command_manager.h @@ -0,0 +1,35 @@ +#ifndef YAZE_APP_EDITOR_SYSTEM_COMMAND_MANAGER_H +#define YAZE_APP_EDITOR_SYSTEM_COMMAND_MANAGER_H + +#include +#include + +namespace yaze { +namespace app { +namespace editor { + +class Command { + public: + virtual ~Command() = default; + virtual void Execute() = 0; +}; + +class CommandManager { + public: + void RegisterCommand(const std::string& shortcut, Command* command) { + commands_[shortcut] = command; + } + + void ExecuteCommand(const std::string& shortcut) { + if (commands_.find(shortcut) != commands_.end()) { + commands_[shortcut]->Execute(); + } + } + + private: + std::unordered_map commands_; +}; + +} // namespace editor +} // namespace app +} // namespace yaze \ No newline at end of file