2018-04-03 15:11:06 +00:00
|
|
|
#pragma once
|
2018-04-20 00:35:05 +00:00
|
|
|
#include "MessageHeader.h"
|
2018-04-03 15:11:06 +00:00
|
|
|
#include "../../util/Serializable.h"
|
|
|
|
#include "../../dml/Record.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace ki
|
|
|
|
{
|
|
|
|
namespace protocol
|
|
|
|
{
|
|
|
|
namespace dml
|
|
|
|
{
|
2018-04-20 00:35:05 +00:00
|
|
|
class MessageTemplate;
|
|
|
|
|
2018-04-03 16:02:30 +00:00
|
|
|
class Message final : public util::Serializable
|
2018-04-03 15:11:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-04-20 00:35:05 +00:00
|
|
|
Message(const MessageTemplate *message_template = nullptr);
|
2018-04-05 16:36:26 +00:00
|
|
|
virtual ~Message();
|
2018-04-03 15:11:06 +00:00
|
|
|
|
2018-04-20 00:35:05 +00:00
|
|
|
const MessageTemplate *get_template() const;
|
|
|
|
void set_template(const MessageTemplate *message_template);
|
2018-04-03 15:11:06 +00:00
|
|
|
|
2018-04-05 16:36:26 +00:00
|
|
|
ki::dml::Record *get_record();
|
|
|
|
const ki::dml::Record *get_record() const;
|
|
|
|
|
2018-04-20 00:35:05 +00:00
|
|
|
ki::dml::FieldBase *get_field(std::string name);
|
|
|
|
const ki::dml::FieldBase *get_field(std::string name) const;
|
|
|
|
|
|
|
|
uint8_t get_service_id() const;
|
|
|
|
uint8_t get_type() const;
|
|
|
|
uint16_t get_message_size() const;
|
|
|
|
std::string get_handler() const;
|
|
|
|
uint8_t get_access_level() const;
|
2018-04-05 16:36:26 +00:00
|
|
|
|
2018-04-03 16:02:30 +00:00
|
|
|
void write_to(std::ostream &ostream) const override final;
|
|
|
|
void read_from(std::istream &istream) override final;
|
|
|
|
size_t get_size() const override final;
|
2018-04-03 15:11:06 +00:00
|
|
|
private:
|
2018-04-20 00:35:05 +00:00
|
|
|
const MessageTemplate *m_template;
|
2018-04-03 15:11:06 +00:00
|
|
|
ki::dml::Record *m_record;
|
2018-04-20 00:35:05 +00:00
|
|
|
|
|
|
|
// This is used to store raw data when a Message is
|
|
|
|
// constructed without a MessageTemplate.
|
|
|
|
MessageHeader m_header;
|
|
|
|
std::vector<char> m_raw_data;
|
2018-04-03 15:11:06 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2018-04-20 00:35:05 +00:00
|
|
|
}
|