#ifndef HOSTS_MGMT_MSG_H
#define HOSTS_MGMT_MSG_H

#include <cstdint>
#include <memory>
#include "core/time.h"
#include "core/types.h"

namespace dofs {

struct MgmtMsg {
        virtual ~MgmtMsg() = default;
        virtual MgmtKind kind() const noexcept = 0;
};

struct HeartbeatMsg final : public MgmtMsg {
        NodeId   subscriber_id;
        NodeStatus status;
        Time     generated_at;

        explicit HeartbeatMsg(NodeId sid, NodeStatus st, Time t) noexcept
                : subscriber_id(sid), status(st), generated_at(t) {}

        MgmtKind kind() const noexcept override {
                return MgmtKind::HEARTBEAT;
        }
};

struct JobFinishedMsg final : public MgmtMsg {
        FlowId flow_id;
        Time   finished_at;

        explicit JobFinishedMsg(FlowId fid, Time t) noexcept
                : flow_id(fid), finished_at(t) {}

        MgmtKind kind() const noexcept override {
                return MgmtKind::JOB_FINISHED;
        }
};

struct EndSimulationMsg final : public MgmtMsg {
        MgmtKind kind() const noexcept override {
                return MgmtKind::END_SIMULATION;
        }
};

using MgmtMsgPtr = std::unique_ptr<MgmtMsg>;

} // namespace dofs

#endif // HOSTS_MGMT_MSG_H
