|
SVCS - English Documentation
|
Integration component for combining multiple command factories. More...
#include <CompositeCommandFactory.hxx>
Public Member Functions | |
| CompositeCommandFactory (std::shared_ptr< ISubject > event_bus, std::shared_ptr< RepositoryManager > repo_manager) | |
| Constructs a CompositeCommandFactory with necessary dependencies. | |
| ~CompositeCommandFactory ()=default | |
| Default destructor. | |
| CompositeCommandFactory (const CompositeCommandFactory &)=delete | |
| Deleted copy constructor. | |
| CompositeCommandFactory & | operator= (const CompositeCommandFactory &)=delete |
| Deleted assignment operator. | |
| void | registerFactory (std::function< std::unique_ptr< ICommand >(const std::string &)> factory) |
| Registers a factory function for command creation. | |
| std::unique_ptr< ICommand > | createCommand (const std::string &name) const |
| Creates a command by name using registered factories. | |
| std::vector< std::string > | getAllCommandNames () const |
| Gets names of all available commands from all factories. | |
| std::string | getCommandDescription (const std::string &name) const |
| Gets the description for a command. | |
| void | showCommandHelp (const std::string &name) const |
| Shows detailed help for a command. | |
| bool | commandExists (const std::string &name) const |
| Checks if a command with the given name exists. | |
| size_t | getFactoryCount () const |
| Gets the number of registered factories. | |
Integration component for combining multiple command factories.
Serves as a bridge between different command subsystems (CLI, Server). When creating a command, it tries each registered factory in order until one successfully creates the command. This design allows clean separation of concerns while providing a unified command interface to the application.
| svcs::integration::CompositeCommandFactory::CompositeCommandFactory | ( | std::shared_ptr< ISubject > | event_bus, |
| std::shared_ptr< RepositoryManager > | repo_manager ) |
Constructs a CompositeCommandFactory with necessary dependencies.
| event_bus | Shared pointer to the event bus for command notifications. |
| repo_manager | Shared pointer to the repository manager for repository operations. |
| bool svcs::integration::CompositeCommandFactory::commandExists | ( | const std::string & | name | ) | const |
Checks if a command with the given name exists.
| name | The name of the command to check. |
Tries to create the command to determine existence.
| std::unique_ptr< ICommand > svcs::integration::CompositeCommandFactory::createCommand | ( | const std::string & | name | ) | const |
Creates a command by name using registered factories.
| name | The name of the command to create. |
Tries each registered factory in order until one successfully creates the command. Returns the first non-null command found.
| std::vector< std::string > svcs::integration::CompositeCommandFactory::getAllCommandNames | ( | ) | const |
Gets names of all available commands from all factories.
Collects command names from all registered factories, removing duplicates. Commands are returned in registration order (factory order), not alphabetical order.
| std::string svcs::integration::CompositeCommandFactory::getCommandDescription | ( | const std::string & | name | ) | const |
Gets the description for a command.
| name | The name of the command. |
Creates a temporary command instance to retrieve its description. If command cannot be created, returns an appropriate error message.
| size_t svcs::integration::CompositeCommandFactory::getFactoryCount | ( | ) | const |
Gets the number of registered factories.
| void svcs::integration::CompositeCommandFactory::registerFactory | ( | std::function< std::unique_ptr< ICommand >(const std::string &)> | factory | ) |
Registers a factory function for command creation.
| factory | Factory function that takes a command name and returns a command pointer. |
Factories are called in the order they are registered until one returns a non-null command. This allows prioritizing certain command types over others.
| void svcs::integration::CompositeCommandFactory::showCommandHelp | ( | const std::string & | name | ) | const |
Shows detailed help for a command.
| name | The name of the command. |
Creates a temporary command instance and calls its showHelp method. If command cannot be created, shows an error message.