#pragma once

#include "ros_bridge/rapidjson/include/rapidjson/document.h"

namespace ros_bridge {
//! @brief Namespace containing classes and methodes ros message generation.
namespace messages {
//! @brief Namespace containing classes and methodes for geometry_msgs generation.
namespace nemo_msgs {
//! @brief Namespace containing methodes for geometry_msgs/GeoPoint message generation.
namespace heartbeat {


std::string messageType();


//! @brief C++ representation of nemo_msgs/Heartbeat message
class Heartbeat{
public:
    Heartbeat(){}
    Heartbeat(int status) :_status(status){}
    Heartbeat(const Heartbeat &heartbeat) : _status(heartbeat.status()){}

    virtual int     status      (void)const    {return _status;}
    virtual void    setStatus   (int status)    {_status = status;}
protected:
    int _status;
};


template <class HeartbeatType>
bool toJson(const HeartbeatType &heartbeat, rapidjson::Value &value, rapidjson::Document::AllocatorType &allocator)
{
    value.AddMember("status", std::int32_t(heartbeat.status()), allocator);
    return true;
}

template <class HeartbeatType>
bool fromJson(const rapidjson::Value &value, HeartbeatType &heartbeat)
{
    if (!value.HasMember("status") || !value["status"].IsInt()){
        assert(false);
        return false;
    }

    heartbeat.setStatus(value["status"].GetInt());
    return true;
}

} // namespace heartbeat
} // namespace nemo_msgs
} // namespace messages
} // namespace ros_bridge
