12 #ifndef DOCWIRE_MESSAGE_H
13 #define DOCWIRE_MESSAGE_H
22 enum class continuation { proceed, skip, stop };
23 struct message_callbacks;
24 using message_sequence_streamer = std::function<continuation(
const message_callbacks&)>;
32 virtual std::type_info
const& object_type()
const noexcept = 0;
35 bool is()
const noexcept
37 return object_type() ==
typeid(T);
42 return static_cast<const message<T>&
>(*this).object;
56 message(T&&
object) : object(std::move(
object)) {}
57 std::type_info
const& object_type()
const noexcept
override
63 using message_ptr = std::shared_ptr<message_base>;
67 std::function<continuation(message_ptr)> m_further;
68 std::function<continuation(message_ptr)> m_back;
70 continuation further(message_ptr msg)
const {
return m_further(std::move(msg)); }
73 continuation further(T&&
object)
const {
return m_further(std::make_shared<
message<T>>(std::forward<T>(
object))); }
75 continuation back(message_ptr msg)
const {
return m_back(std::move(msg)); }
78 continuation back(T&&
object)
const {
return m_back(std::make_shared<
message<T>>(std::forward<T>(
object))); }
80 continuation operator()(message_ptr msg)
const {
return further(std::move(msg)); }
83 continuation operator()(T&&
object)
const {
return further(std::forward<T>(
object)); }
The main namespace for the DocWire SDK.