Refactor command system - remove BaseCommand class implementation in favour of std::function

This commit is contained in:
Lorow
2025-04-09 21:43:49 +02:00
parent 8a2695977c
commit eaa60cb877
17 changed files with 268 additions and 271 deletions

View File

@@ -1,30 +1,14 @@
#include "BaseCommand.hpp"
#include <ProjectConfig.hpp>
#include <memory>
#include <string>
#include <optional>
#include <cJSON.h>
#include "CommandResult.hpp"
#include "CommandSchema.hpp"
#include "DependencyRegistry.hpp"
class saveConfigCommand : public Command
{
public:
std::shared_ptr<ProjectConfig> projectConfig;
saveConfigCommand(std::shared_ptr<ProjectConfig> projectConfig) : projectConfig(projectConfig) {};
CommandResult execute(std::string_view jsonPayload) override;
};
CommandResult saveConfigCommand(std::shared_ptr<DependencyRegistry> registry);
CommandResult getConfigCommand(std::shared_ptr<DependencyRegistry> registry);
class getConfigCommand : public Command
{
public:
std::shared_ptr<ProjectConfig> projectConfig;
getConfigCommand(std::shared_ptr<ProjectConfig> projectConfig) : projectConfig(projectConfig) {};
CommandResult execute(std::string_view jsonPayload) override;
};
class resetConfigCommand : public Command
{
std::array<std::string, 4> supported_sections = {
"all",
};
public:
std::shared_ptr<ProjectConfig> projectConfig;
resetConfigCommand(std::shared_ptr<ProjectConfig> projectConfig) : projectConfig(projectConfig) {};
CommandResult execute(std::string_view jsonPayload) override;
std::optional<ResetConfigPayload> parsePayload(std::string_view jsonPayload);
};
std::optional<ResetConfigPayload> parseresetConfigCommandPayload(std::string_view jsonPayload);
CommandResult resetConfigCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);