#pragma once #include "google/protobuf/any.pb.h" #include "google/protobuf/message.h" #include #include #include #include #include namespace WHISPER { enum MsgType : int32_t { /// message to shutdown all participants SHUTDOWN = 0, /// on participant is joined JOIN=1, /// participant is leaving LEAVE, /// PING PING, /// PONG PONG, /// general Sim track SIM_TRACK, /// owntrack informaton OWN_TRACK, /// raw track message GROUND_TRUTH_TRACK, /// radar track RADAR_TRACK, /// esm track ESM_TRACK, /// SENSOR Track message SENSOR_TRACK, /// simple data SIMPLE, ///dummy string Data STRINGDATA, /// Command messages COMMAND }; // enum class EventType enum MsgTopics : uint32_t { MANAGEMENT, DATA, COMMANDS, TRACK }; static std::mapMsgTopicsMap = { {MsgTopics::MANAGEMENT, "Management"}, {MsgTopics::DATA, "Data"}, {MsgTopics::COMMANDS, "Commands"}, {MsgTopics::TRACK, "Track"}, }; enum SourceType : uint32_t { SIMCOMTROLER, /// ENTITY, /// SENSOR, /// EFEKTOR, /// GATEWAY, /// }; // enum class EventType /** * @brief the message class is the basic sending an receiving class * it is part of every message an every received string is first deserilized as a Message * */ class Message{ private: /// the serialized payload std::string payloadString_; /// shared pointer to the payload protobuf message std::shared_ptr payload_; public: Message()=default; Message(std::string senderUUID, MsgTopics topic, MsgType Type,SourceType src); [[deprecated]] Message(std::uint32_t parentId,std::uint32_t deviceId, MsgTopics topic, MsgType Type,SourceType src); Message(std::string msg); /** * @brief returns the payload string * @return std::string */ std::string getPayloadString(); ///topic of the message for pub sub std::uint32_t topic_; /// WHISPER::MsgType ot the payload std::uint32_t msgType_; /// WHISPER::SourceType of the sender std::uint32_t sourceType_; ///sender uuid std::string senderUUID_; /// id of the sender std::uint32_t deviceId_; /// parent id of the sender 0 if its the manager std::uint32_t parentId_; /** * @brief returns the serialized message * @return std::string * */ std::string serialize(); /** * @brief adds the payload with type of shared_prt of protbuf::any * @param std::shared_ptr */ void addPayLoad(std::shared_ptr any); messages::header::Message getProtoMessage(); protected: // void addPayLoad(std::string any); /// protobuf message; our header message messages::header::Message msg; }; }