/* * ===================================================================================== * * Filename: msg.h * * Description: * * Version: 1.0 * Created: 2021年03月24日 16时49分20秒 * Revision: none * Compiler: gcc * * Author: Li Chao (), * Organization: * * ===================================================================================== */ #ifndef MSG_5BILLZET #define MSG_5BILLZET #include #include namespace bhome_shm { using namespace boost::interprocess; // safe to be stored in shared memory. // message format: header(meta) + body(data). enum MsgType { kMsgTypeNull = 0, kMsgTypeNormal = 1, kMsgTypeMaxValue }; const uint32_t kMsgMetaTag = 0xf1e2d3c4; struct MsgMetaV1 { uint16_t self_size_ = sizeof(MsgMetaV1); // sizeof(*this) uint16_t type_ = kMsgTypeNormal; // msg type. uint32_t tag_ = kMsgMetaTag; uint32_t data_size_ = 0; unsigned char src_id_[16] = {0}; // more fields add at end, must not change MsgMetaV1(){} bool Parse(const void *p); void Pack(void *p); }; typedef offset_ptr Msg; } // namespace bhome_shm #endif // end of include guard: MSG_5BILLZET