2018-04-03 15:11:06 +00:00
|
|
|
#pragma once
|
2018-04-20 00:35:05 +00:00
|
|
|
#include "Message.h"
|
2018-04-03 15:11:06 +00:00
|
|
|
#include "MessageModule.h"
|
|
|
|
#include "../../dml/Record.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace ki
|
|
|
|
{
|
|
|
|
namespace protocol
|
|
|
|
{
|
|
|
|
namespace dml
|
|
|
|
{
|
|
|
|
class MessageManager
|
|
|
|
{
|
|
|
|
public:
|
2018-04-05 16:36:26 +00:00
|
|
|
MessageManager() = default;
|
2018-04-03 15:11:06 +00:00
|
|
|
~MessageManager();
|
|
|
|
|
2018-04-05 16:36:26 +00:00
|
|
|
const MessageModule *load_module(std::string filepath);
|
2020-12-07 00:09:51 +00:00
|
|
|
void load_module(MessageModule* module);
|
|
|
|
|
2018-04-05 16:36:26 +00:00
|
|
|
const MessageModule *get_module(uint8_t service_id) const;
|
|
|
|
const MessageModule *get_module(const std::string &protocol_type) const;
|
2018-04-03 15:11:06 +00:00
|
|
|
|
2018-04-20 00:35:05 +00:00
|
|
|
Message *create_message(uint8_t service_id, uint8_t message_type) const;
|
|
|
|
Message *create_message(uint8_t service_id, const std::string &message_name) const;
|
|
|
|
Message *create_message(const std::string &protocol_type, uint8_t message_type) const;
|
|
|
|
Message *create_message(const std::string &protocol_type, const std::string &message_name) const;
|
2018-04-03 15:11:06 +00:00
|
|
|
|
2018-04-05 16:36:26 +00:00
|
|
|
/**
|
|
|
|
* If the DML message header cannot be read, then a nullptr
|
|
|
|
* is returned; otherwise, a valid Message pointer is always returned.
|
|
|
|
* However, that does not mean that the message itself is valid.
|
|
|
|
*
|
|
|
|
* To verify if the record was completely parsed, get_record
|
|
|
|
* should return a valid Record pointer, rather than nullptr.
|
|
|
|
*/
|
|
|
|
const Message *message_from_binary(std::istream &istream) const;
|
2018-04-03 15:11:06 +00:00
|
|
|
private:
|
|
|
|
MessageModuleList m_modules;
|
|
|
|
MessageModuleServiceIdMap m_service_id_map;
|
|
|
|
MessageModuleProtocolTypeMap m_protocol_type_map;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|