feat add dispatcher to sled.h
Some checks failed
linux-x64-gcc / linux-gcc (Release) (push) Failing after 41s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 1m2s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 1m6s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m4s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 1m10s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 1m17s
Some checks failed
linux-x64-gcc / linux-gcc (Release) (push) Failing after 41s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 1m2s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 1m6s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m4s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 1m10s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 1m17s
This commit is contained in:
parent
cc7d131d95
commit
6caa48d801
@ -4,6 +4,7 @@
|
|||||||
#include "sled/synchronization/mutex.h"
|
#include "sled/synchronization/mutex.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace sled {
|
namespace sled {
|
||||||
namespace experimental {
|
namespace experimental {
|
||||||
@ -11,12 +12,13 @@ namespace experimental {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class Dispatcher {
|
class Dispatcher {
|
||||||
public:
|
public:
|
||||||
|
static_assert(!std::is_rvalue_reference<T>::value, "must be a value type");
|
||||||
enum class DispatchResult { kHandled, kNotFound };
|
enum class DispatchResult { kHandled, kNotFound };
|
||||||
|
|
||||||
struct Handler {
|
struct Handler {
|
||||||
virtual ~Handler() = default;
|
virtual ~Handler() = default;
|
||||||
virtual bool HandleMessage(const T &) = 0;
|
virtual bool HandleMessage(const T &) = 0;
|
||||||
virtual bool OnMessage(T &&) = 0;
|
virtual bool OnMessage(const T &) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Dispatcher() = default;
|
virtual ~Dispatcher() = default;
|
||||||
|
@ -9,6 +9,9 @@ namespace async {}
|
|||||||
#include "inja.hpp"
|
#include "inja.hpp"
|
||||||
#include "rx.h"
|
#include "rx.h"
|
||||||
|
|
||||||
|
// experimental
|
||||||
|
#include "sled/experimental/design_patterns/dispatcher.h"
|
||||||
|
|
||||||
// event_bus
|
// event_bus
|
||||||
#include "sled/event_bus/event_bus.h"
|
#include "sled/event_bus/event_bus.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user