72class [[nodiscard]] AsyncEventSubscriberScope
final {
74 AsyncEventSubscriberScope() =
default;
76 AsyncEventSubscriberScope(AsyncEventSubscriberScope&& scope)
noexcept;
77 AsyncEventSubscriberScope& operator=(AsyncEventSubscriberScope&& other)
noexcept;
78 ~AsyncEventSubscriberScope();
86 template <
typename... Args>
87 AsyncEventSubscriberScope(utils::
impl::InternalTag, AsyncEventSource<Args...>& channel, FunctionId id)
88 : AsyncEventSubscriberScope(
static_cast<impl::AsyncEventSourceBase&>(channel), id)
93 AsyncEventSubscriberScope(impl::AsyncEventSourceBase& channel, FunctionId id);
95 impl::AsyncEventSourceBase* channel_{
nullptr};
106class AsyncEventSource :
public impl::AsyncEventSourceBase {
108 using Function = std::function<
void(Args... args)>;
110 virtual ~AsyncEventSource() =
default;
132 template <
class Class>
133 AsyncEventSubscriberScope
AddListener(Class* obj, std::string_view name,
void (Class::*func)(Args...)) {
134 return AddListener(FunctionId(obj), name, [obj, func](Args... args) { (obj->*func)(args...); });
142 AsyncEventSubscriberScope
AddListener(FunctionId id, std::string_view name, Function&& func) {
143 return DoAddListener(id, name, std::move(func));
150 virtual AsyncEventSubscriberScope DoAddListener(FunctionId id, std::string_view name, Function&& func) = 0;