SVCS - Русская документация
Загрузка...
Поиск...
Не найдено
CommandFactory.hxx
См. документацию.
1
13#pragma once
14
18
19#include <memory>
20#include <unordered_map>
21#include <functional>
22#include <string>
23#include <vector>
24
38namespace svcs::cli {
39
40using namespace svcs::core;
41
57class CommandFactory {
58private:
66 std::shared_ptr<ISubject> event_bus;
67
75 std::shared_ptr<RepositoryManager> repo_manager;
76
90 std::unordered_map<std::string,
91 std::function<std::unique_ptr<ICommand>(std::shared_ptr<ISubject>,
92 std::shared_ptr<RepositoryManager>)>> creators;
93
103 void registerDefaultCommands();
104
105public:
117 explicit CommandFactory(std::shared_ptr<ISubject> bus,
118 std::shared_ptr<RepositoryManager> repoManager);
119
123
127 CommandFactory(const CommandFactory&) = delete;
128
136 CommandFactory& operator=(const CommandFactory&) = delete;
137
149 void registerCommand(const std::string& name,
150 std::function<std::unique_ptr<ICommand>(std::shared_ptr<ISubject>,
151 std::shared_ptr<RepositoryManager>)> creator);
152
166 std::string getCommandDescription(const std::string& name) const;
167
179 void showCommandHelp(const std::string& name) const;
180
194 std::unique_ptr<ICommand> createCommand(const std::string& name) const;
195
205 std::vector<std::string> getRegisteredCommands() const;
206};
207
208}
Объявление интерфейса ICommand для всех исполняемых CLI команд.
Определяет интерфейс для компонента Subject (Издатель) шаблона Observer.
Declaration of the RepositoryManager class, managing all repository-level file operations.
void registerCommand(const std::string &name, std::function< std::unique_ptr< ICommand >(std::shared_ptr< ISubject >, std::shared_ptr< RepositoryManager >)> creator)
Регистрирует функцию-создатель для новой команды.
Определения CommandFactory.cxx:163
std::string getCommandDescription(const std::string &name) const
Получает краткое описание для зарегистрированной команды.
Определения CommandFactory.cxx:146
CommandFactory & operator=(const CommandFactory &)=delete
Удаляет оператор присваивания. Фабрика не должна присваиваться.
std::unique_ptr< ICommand > createCommand(const std::string &name) const
Создает и возвращает объект команды по его имени.
Определения CommandFactory.cxx:170
std::vector< std::string > getRegisteredCommands() const
Получает список имен всех текущих зарегистрированных команд.
Определения CommandFactory.cxx:181
CommandFactory(std::shared_ptr< ISubject > bus, std::shared_ptr< RepositoryManager > repoManager)
Конструирует CommandFactory.
Определения CommandFactory.cxx:40
void showCommandHelp(const std::string &name) const
Отображает подробную справку и использование для зарегистрированной команды.
Определения CommandFactory.cxx:153
Компоненты командной строки и реализации команд.
Основные структуры данных СКВ и модель объектов.