70class [[nodiscard]] AsyncEventSubscriberScope
final {
72 AsyncEventSubscriberScope() =
default;
74 AsyncEventSubscriberScope(AsyncEventSubscriberScope&& scope)
noexcept;
75 AsyncEventSubscriberScope& operator=(AsyncEventSubscriberScope&& other)
noexcept;
76 ~AsyncEventSubscriberScope();
84 template <
typename... Args>
85 AsyncEventSubscriberScope(
utils::impl::InternalTag, AsyncEventSource<Args...>& channel, FunctionId id)
86 : AsyncEventSubscriberScope(
static_cast<impl::AsyncEventSourceBase&>(channel), id) {}
90 AsyncEventSubscriberScope(impl::AsyncEventSourceBase& channel, FunctionId id);
92 impl::AsyncEventSourceBase* channel_{
nullptr};
103class AsyncEventSource :
public impl::AsyncEventSourceBase {
105 using Function = std::function<
void(Args... args)>;
107 virtual ~AsyncEventSource() =
default;
129 template <
class Class>
130 AsyncEventSubscriberScope
AddListener(Class* obj, std::string_view name,
void (Class::*func)(Args...)) {
131 return AddListener(FunctionId(obj), name, [obj, func](Args... args) { (obj->*func)(args...); });
130 AsyncEventSubscriberScope
AddListener(Class* obj, std::string_view name,
void (Class::*func)(Args...)) {
…}
139 AsyncEventSubscriberScope
AddListener(FunctionId id, std::string_view name, Function&& func) {
140 return DoAddListener(id, name, std::move(func));
139 AsyncEventSubscriberScope
AddListener(FunctionId id, std::string_view name, Function&& func) {
…}
147 virtual AsyncEventSubscriberScope DoAddListener(FunctionId id, std::string_view name, Function&& func) = 0;