-
Notifications
You must be signed in to change notification settings - Fork 0
/
IMessage.hh
39 lines (26 loc) · 946 Bytes
/
IMessage.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include "MessageType.hh"
#include <core_utils/CoreObject.hh>
#include <memory>
namespace bsgo {
class IMessage : public utils::CoreObject
{
public:
IMessage(const std::string &name);
~IMessage() override = default;
virtual auto type() const -> MessageType = 0;
virtual auto serialize(std::ostream &out) const -> std::ostream & = 0;
virtual bool deserialize(std::istream &in) = 0;
virtual auto clone() const -> std::unique_ptr<IMessage> = 0;
template<typename Message>
auto as() -> Message &;
template<typename Message>
auto as() const -> const Message &;
template<typename Message>
bool isA() const;
};
using IMessagePtr = std::unique_ptr<IMessage>;
auto operator<<(std::ostream &out, const IMessage &message) -> std::ostream &;
auto operator>>(std::istream &in, IMessage &message) -> std::istream &;
} // namespace bsgo
#include "IMessage.hxx"