SVCS - English Documentation
Loading...
Searching...
No Matches
CompositeCommandFactory.hxx
Go to the documentation of this file.
1
19#pragma once
20
24
25#include <memory>
26#include <vector>
27#include <functional>
28#include <string>
29#include <unordered_set>
30
48namespace svcs::integration {
50using namespace svcs::core;
51using namespace svcs::cli;
52using namespace svcs::services;
53
72public:
84 CompositeCommandFactory(std::shared_ptr<ISubject> event_bus,
85 std::shared_ptr<RepositoryManager> repo_manager);
86
94 ~CompositeCommandFactory() = default;
95
104
113
127 void registerFactory(std::function<std::unique_ptr<ICommand>(const std::string&)> factory);
128
144 std::unique_ptr<ICommand> createCommand(const std::string& name) const;
145
159 std::vector<std::string> getAllCommandNames() const;
160
161
176 std::string getCommandDescription(const std::string& name) const;
177
191 void showCommandHelp(const std::string& name) const;
192
206 bool commandExists(const std::string& name) const;
207
217 size_t getFactoryCount() const;
218
219private:
227 std::shared_ptr<ISubject> event_bus_;
228
236 std::shared_ptr<RepositoryManager> repo_manager_;
237
247 std::vector<std::function<std::unique_ptr<ICommand>(const std::string&)>> factories_;
248};
249
250}
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 registerFactory(std::function< std::unique_ptr< ICommand >(const std::string &)> factory)
Registers a factory function for command creation.
Definition CompositeCommandFactory.cxx:42
CompositeCommandFactory & operator=(const CompositeCommandFactory &)=delete
Deleted assignment operator.
size_t getFactoryCount() const
Gets the number of registered factories.
Definition CompositeCommandFactory.cxx:111
bool commandExists(const std::string &name) const
Checks if a command with the given name exists.
Definition CompositeCommandFactory.cxx:107
~CompositeCommandFactory()=default
Default destructor.
void showCommandHelp(const std::string &name) const
Shows detailed help for a command.
Definition CompositeCommandFactory.cxx:97
std::vector< std::string > getAllCommandNames() const
Gets names of all available commands from all factories.
Definition CompositeCommandFactory.cxx:56
std::unique_ptr< ICommand > createCommand(const std::string &name) const
Creates a command by name using registered factories.
Definition CompositeCommandFactory.cxx:46
std::string getCommandDescription(const std::string &name) const
Gets the description for a command.
Definition CompositeCommandFactory.cxx:89
CompositeCommandFactory(std::shared_ptr< ISubject > event_bus, std::shared_ptr< RepositoryManager > repo_manager)
Constructs a CompositeCommandFactory with necessary dependencies.
Definition CompositeCommandFactory.cxx:26
Command-line interface components and command implementations.
Core VCS data structures and object model.
System integration components and cross-cutting concerns.
Service layer components and infrastructure services.