#ifndef MESSAGE_H #define MESSAGE_H #include "payload.h" #include #include #include class Message { private: Message(); std::size_t deserialize_size; friend class ConnectionBase; //! Serialize message. std::pair serialize(); //! Deserialize message. std::size_t deserialize(uint8_t* data, std::size_t bytes); Payload::Type payload_type; Payload::Base* payload_data; public: typedef boost::shared_ptr p; static p create(); //! Return payload type. Payload::Type type(); //! Return reference to payload. template T& payload() { return dynamic_cast(*payload_data); } }; #endif