#ifndef MESSAGE #define MESSAGE #include #include #include namespace CommService { enum messageTopic : std::uint16_t { /// udp client joins LOCAL_JOIN, /// local udp clients leave LOCAL_LEAVE, /// remote participant joins the sim JOIN, /// remote participant leave the sim LEAVE, /// sends id to participant ID_MESSAGE }; enum deviceMajorType : std::uint16_t { ID_SERVICE, GATEWAY, CIVIL_SHIP, WAR_SHIP, RADAR, SONAR, WEAPON }; class Message : public transmittable{ public: // the device id of the device/endpoint sending this Message std::uint16_t sourceID; /// the major type of the device/endpoint transmitting this message deviceMajorType srcMajorType; /// the minor type of the device/endpoint transmitting this message std::string srcMinorType; /// which topic does this message have ? helps identifying the transmitted datatype messageTopic topic; Message(); /** * @brief Constructor for generationg a Message object from a received std::vector * * @param v - the std::vector representing a message object */ Message(std::vector); /** * @brief Copy constructor of the Message class * * creates a copy of the object, including copies of all data * * @param obj - the object from which to copy everything */ Message(const Message &obj); void setData(const transmittable &d){data=d.toByteVector();} /** * @brief converts the whole message information into a byte vector * * all information of the message class is converted into a byte vector for transmission * through any kind of network. * * @param payload - returns the byte vector by call by reference */ std::vector toByteVector() const override; /** * @brief return the raw byte vector of the data object, required for data reception * * @return the std::vector */ std::vector getRawData() const {return data;} private: std::vector data; }; }; #endif