Factory for creating server administration ICommand objects.
More...
#include <ServerCommandFactory.hxx>
Factory for creating server administration ICommand objects.
The ServerCommandFactory manages the lifecycle of server-specific commands, creating them dynamically using creator functions registered under unique names. Commands are constructed with shared ownership of an event bus (ISubject) and a repository manager (RepositoryManager). This factory is specifically designed for server administration commands that require repository management.
◆ ServerCommandFactory()
| svcs::server::cli::ServerCommandFactory::ServerCommandFactory |
( |
std::shared_ptr< ISubject > | bus, |
|
|
std::shared_ptr< RepositoryManager > | repoManager ) |
|
explicit |
Constructs the ServerCommandFactory.
- Parameters
-
| bus | A shared pointer to the event bus. |
| repoManager | A shared pointer to the repository manager. |
◆ commandExists()
| bool svcs::server::cli::ServerCommandFactory::commandExists |
( |
const std::string & | name | ) |
const |
Checks if a server command with the given name exists.
- Parameters
-
| name | The name of the server command to check. |
- Returns
- True if the command exists and can be created, false otherwise.
◆ createCommand()
| std::unique_ptr< ICommand > svcs::server::cli::ServerCommandFactory::createCommand |
( |
const std::string & | name | ) |
const |
Creates and returns a server command object by its name.
Transfers ownership (via unique_ptr) of the created object to the caller.
- Parameters
-
| name | The name of the server command (the key in the creators map). |
- Returns
- std::unique_ptr<ICommand> holding a new command object, or nullptr if the command is not registered.
◆ getCommandDescription()
| std::string svcs::server::cli::ServerCommandFactory::getCommandDescription |
( |
const std::string & | name | ) |
const |
Retrieves the brief description for a registered server command.
Creates a temporary instance of the command to retrieve its description.
- Parameters
-
| name | The name of the server command. |
- Returns
- The command's description string, or an error message if the command is not registered.
◆ getRegisteredCommands()
| std::vector< std::string > svcs::server::cli::ServerCommandFactory::getRegisteredCommands |
( |
| ) |
const |
Retrieves a list of names for all currently registered server commands.
- Returns
- A vector of strings containing the names of all registered server commands.
◆ registerCommand()
| void svcs::server::cli::ServerCommandFactory::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.
- Parameters
-
| name | The string name under which the server command will be callable. |
| creator | The function that creates and returns a new ICommand object. |
◆ showCommandHelp()
| void svcs::server::cli::ServerCommandFactory::showCommandHelp |
( |
const std::string & | name | ) |
const |
Displays the detailed help and usage for a registered server command.
Creates a temporary command instance and calls its showHelp method.
- Parameters
-
| name | The name of the server command. |
The documentation for this class was generated from the following files: