OpenHiva::HivaMessage

OpenHiva::HivaMessage is a common message type for framework publishing and subscription. It contains message serialization and deserialization interfaces.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
namespace Hiva {
namespace StdMsgs {
class HivaMessage {
public:
    HivaMessage() = default;
    virtual ~HivaMessage() = default;
    virtual bool Serialize(HivaSerializer &serializer) const = 0;
    virtual bool Deserialize(HivaSerializer &serializer) = 0;
    virtual uint32_t GetSerializedLength(HivaSerializer &serializer) const = 0;
    virtual const Hiva::HivaTime &GetTimeStamp() const = 0;  // Obtain the timestamp when a message is generated and store the timestamp in the message header. This parameter is valid only when HasHeader is set to true.
    virtual uint32_t GetSequenceId() const = 0;              // Obtain the sequence number (SN) of a message and store the SN in the message header. This parameter is valid only when HasHeader is set to true.
    // The following interfaces describe the message attributes, which must be implemented in each subclass.
    static bool HasHeader();                    // Indicates whether a message header exists.
    static std::string GetDataType();           // Message type
    static std::string GetMD5Sum();             // MD5 value of a message. The MD5 value of each message is different.
    static std::string GetDefinition();         // Message definition, which describes the member variables in a message in detail.
};
}
}
using OpenHiva::HivaMessage = Hiva::StdMsgs::HivaMessage;