libki/include/ki/protocol/dml/MessageManager.h

45 lines
1.3 KiB
C
Raw Permalink Normal View History

2018-04-03 15:11:06 +00:00
#pragma once
#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:
MessageManager() = default;
2018-04-03 15:11:06 +00:00
~MessageManager();
const MessageModule *load_module(std::string filepath);
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
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
/**
* 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;
};
}
}
}