#include "rpc_server.hpp"
#include "vm_provider.hpp"
#include <memory>

namespace sliger::rpc::action {

struct Action {
    virtual auto perform_action(std::unique_ptr<BufferedWriter> writer,
        VmProvider& vm_provider) -> void = 0;
    virtual ~Action() = default;
};

class Status : public Action {
public:
    Status() { }
    auto perform_action(std::unique_ptr<BufferedWriter> writer,
        VmProvider& vm_provider) -> void;
};

class FlameGraph : public Action {
public:
    FlameGraph() { }
    auto perform_action(std::unique_ptr<BufferedWriter> writer,
        VmProvider& vm_provider) -> void;
};

class CodeCoverage : public Action {
public:
    CodeCoverage() { }
    auto perform_action(std::unique_ptr<BufferedWriter> writer,
        VmProvider& vm_provider) -> void;
};

class RunDebug : public Action {
public:
    RunDebug(std::vector<uint32_t> instructions)
        : instructions(instructions)
    {
    }
    auto perform_action(std::unique_ptr<BufferedWriter> writer,
        VmProvider& vm_provider) -> void;

private:
    std::vector<uint32_t> instructions;
};

auto action_from_json(const json::Value& value) -> std::unique_ptr<Action>;

}
