2022-04-17 23:55:34 +01:00
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-29 22:06:05 +01:00
|
|
|
[[nodiscard]] virtual bool requiresStoppedTargetState() const {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 16:13:43 +01:00
|
|
|
[[nodiscard]] virtual bool requiresDebugMode() const {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-17 23:55:34 +01:00
|
|
|
private:
|
|
|
|
|
static inline std::atomic<CommandIdType> lastCommandId = 0;
|
|
|
|
|
};
|
|
|
|
|
}
|