SVCS - Русская документация
Загрузка...
Поиск...
Не найдено
ServerCommandFactory.hxx
См. документацию.
1
17#pragma once
18
22
23#include <memory>
24#include <unordered_map>
25#include <functional>
26#include <string>
27#include <vector>
28
45 */
46namespace svcs::server::cli {
47
48using namespace svcs::core;
49using namespace svcs::cli;
50using namespace svcs::services;
51
70private:
78 std::shared_ptr<ISubject> event_bus;
79
87 std::shared_ptr<RepositoryManager> repo_manager;
88
102 std::unordered_map<std::string,
103 std::function<std::unique_ptr<ICommand>(std::shared_ptr<ISubject>,
104 std::shared_ptr<RepositoryManager>)>> creators;
105
117 void registerDefaultCommands();
118
119public:
131 explicit ServerCommandFactory(std::shared_ptr<ISubject> bus,
132 std::shared_ptr<RepositoryManager> repoManager);
133
138
142
151
163 void registerCommand(const std::string& name,
164 std::function<std::unique_ptr<ICommand>(std::shared_ptr<ISubject>,
165 std::shared_ptr<RepositoryManager>)> creator);
166
180 std::string getCommandDescription(const std::string& name) const;
181
193 void showCommandHelp(const std::string& name) const;
194
208 std::unique_ptr<ICommand> createCommand(const std::string& name) const;
209
219 std::vector<std::string> getRegisteredCommands() const;
220
232 bool commandExists(const std::string& name) const;
233};
234
235}
Объявление интерфейса ICommand для всех исполняемых CLI команд.
Определяет интерфейс для компонента Subject (Издатель) шаблона Observer.
Declaration of the RepositoryManager class, managing all repository-level file operations.
void showCommandHelp(const std::string &name) const
Отображает подробную справку и использование для зарегистрированной серверной команды.
Определения ServerCommandFactory.cxx:54
std::vector< std::string > getRegisteredCommands() const
Получает список имен всех текущих зарегистрированных серверных команд.
Определения ServerCommandFactory.cxx:71
ServerCommandFactory & operator=(const ServerCommandFactory &)=delete
Удаляет оператор присваивания. Серверная Фабрика не должна присваиваться.
std::string getCommandDescription(const std::string &name) const
Получает краткое описание для зарегистрированной серверной команды.
Определения ServerCommandFactory.cxx:46
ServerCommandFactory(std::shared_ptr< ISubject > bus, std::shared_ptr< RepositoryManager > repoManager)
Конструирует ServerCommandFactory.
Определения ServerCommandFactory.cxx:20
void registerCommand(const std::string &name, std::function< std::unique_ptr< ICommand >(std::shared_ptr< ISubject >, std::shared_ptr< RepositoryManager >)> creator)
Регистрирует функцию-создатель для новой серверной команды.
Определения ServerCommandFactory.cxx:40
std::unique_ptr< ICommand > createCommand(const std::string &name) const
Создает и возвращает объект серверной команды по его имени.
Определения ServerCommandFactory.cxx:63
bool commandExists(const std::string &name) const
Проверяет, существует ли серверная команда с заданным именем.
Определения ServerCommandFactory.cxx:79
Компоненты командной строки и реализации команд.
Основные структуры данных СКВ и модель объектов.
Компоненты командной строки для администрирования сервера.
Компоненты сервисного слоя и инфраструктурные сервисы.