Implemented new command-response-based interface for the TargetController

This commit is contained in:
Nav
2022-04-17 23:55:34 +01:00
parent 8d26340c41
commit 13f5c13065
9 changed files with 440 additions and 111 deletions

View File

@@ -0,0 +1,42 @@
#pragma once
#include <string>
#include <atomic>
#include <cstdint>
#include "CommandTypes.hpp"
#include "src/TargetController/Responses/Response.hpp"
namespace Bloom::TargetController::Commands
{
using CommandIdType = int;
static_assert(std::atomic<CommandIdType>::is_always_lock_free);
class Command
{
public:
using SuccessResponseType = Responses::Response;
CommandIdType id = ++(Command::lastCommandId);
static constexpr CommandType type = CommandType::GENERIC;
static inline const std::string name = "GenericCommand";
Command() = default;
virtual ~Command() = default;
Command(const Command& other) = default;
Command(Command&& other) = default;
Command& operator = (const Command& other) = default;
Command& operator = (Command&& other) = default;
[[nodiscard]] virtual CommandType getType() const {
return Command::type;
}
private:
static inline std::atomic<CommandIdType> lastCommandId = 0;
};
}

View File

@@ -0,0 +1,11 @@
#pragma once
#include <cstdint>
namespace Bloom::TargetController::Commands
{
enum class CommandType: std::uint8_t
{
GENERIC,
};
}