template<typename T>
void add_observer(EventObserver &obs, std::function<void(const T &)> cb)
- { static_cast<EventDispatcher<T> &>(*this).add_observer(obs, std::move(cb)); }
+ { static_cast<EventDispatcher<T> &>(*this).add_observer(&obs, std::move(cb)); }
void remove_observer(EventObserver &obs) override
{ (static_cast<EventDispatcher<E> &>(*this).remove_observer(&obs), ...); }
public:
template<typename T, typename... Args>
void emit(Args &&...) const;
+
+ template<typename T, typename... Args>
+ void emit_to(EventObserver &, Args &&...) const;
};
bus.dispatch(event);
}
+template<typename... E>
+template<typename T, typename... Args>
+inline void EventSource<E...>::emit_to(EventObserver &obs, Args &&... args) const
+{
+ T event(std::forward<Args>(args)...);
+ static_cast<const EventDispatcher<T> &>(*this).dispatch_to(obs, event);
+ bus.dispatch_to(obs, event);
+}
+
} // namespace Msp::Game
#endif