SVCS - English Documentation
Loading...
Searching...
No Matches
ServerCommandFactory.hxx
Go to the documentation of this file.
1
17#pragma once
18
22
23#include <memory>
24#include <unordered_map>
25#include <functional>
26#include <string>
27#include <vector>
28
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
142
151
154
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}
Declaration of the ICommand interface for all executable CLI commands.
Defines the interface for the Subject (Publisher) component of the Observer pattern.
Declaration of the RepositoryManager class, managing all repository-level file operations.
void showCommandHelp(const std::string &name) const
Displays the detailed help and usage for a registered server command.
Definition ServerCommandFactory.cxx:55
std::vector< std::string > getRegisteredCommands() const
Retrieves a list of names for all currently registered server commands.
Definition ServerCommandFactory.cxx:72
ServerCommandFactory & operator=(const ServerCommandFactory &)=delete
Deletes the assignment operator. The Server Factory should not be assigned.
std::string getCommandDescription(const std::string &name) const
Retrieves the brief description for a registered server command.
Definition ServerCommandFactory.cxx:47
ServerCommandFactory(std::shared_ptr< ISubject > bus, std::shared_ptr< RepositoryManager > repoManager)
Constructs the ServerCommandFactory.
Definition ServerCommandFactory.cxx:21
void registerCommand(const std::string &name, std::function< std::unique_ptr< ICommand >(std::shared_ptr< ISubject >, std::shared_ptr< RepositoryManager >)> creator)
Registers a creator function for a new server command.
Definition ServerCommandFactory.cxx:41
std::unique_ptr< ICommand > createCommand(const std::string &name) const
Creates and returns a server command object by its name.
Definition ServerCommandFactory.cxx:64
bool commandExists(const std::string &name) const
Checks if a server command with the given name exists.
Definition ServerCommandFactory.cxx:80
Command-line interface components and command implementations.
Core VCS data structures and object model.
Server administration command-line interface components.
Service layer components and infrastructure services.