qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::router::semh< _RawEvent, void > Class Template Reference

Single-Event Multiple-Handler router (heterogeneous version) More...

#include <router.h>

Inheritance diagram for qb::router::semh< _RawEvent, void >:
Collaboration diagram for qb::router::semh< _RawEvent, void >:

Public Member Functions

 ~semh () noexcept
 Destructor that cleans up all handler resolvers.
template<bool _CleanEvent = false>
void route (_RawEvent &event) const noexcept
 Routes an event to the appropriate handler.
template<typename _Handler>
void subscribe (_Handler &handler) noexcept
 Subscribe a handler to receive events.
void unsubscribe (_HandlerId const &id) noexcept
 Unsubscribe a handler by ID.

Additional Inherited Members

Protected Member Functions inherited from qb::router::internal::EventPolicy
template<typename _Handler, typename _Event>
void invoke (_Handler &handler, _Event &event) const
 Invoke a handler with an event.
template<typename _Event>
void dispose (_Event &event) const noexcept
 Dispose of an event if necessary.

Detailed Description

template<typename _RawEvent>
class qb::router::semh< _RawEvent, void >

Single-Event Multiple-Handler router (heterogeneous version)

Specialization that supports different handler types for the same event type.

Template Parameters
_RawEventThe event type

Member Function Documentation

◆ route()

template<typename _RawEvent>
template<bool _CleanEvent = false>
void qb::router::semh< _RawEvent, void >::route ( _RawEvent & event) const
inlinenoexcept

Routes an event to the appropriate handler.

If the event has a broadcast destination, it's sent to all handlers. Otherwise, it's sent to the handler that matches the destination ID.

Template Parameters
_CleanEventWhether to clean up the event after routing
Parameters
eventThe event to route

◆ subscribe()

template<typename _RawEvent>
template<typename _Handler>
void qb::router::semh< _RawEvent, void >::subscribe ( _Handler & handler)
inlinenoexcept

Subscribe a handler to receive events.

Creates a handler resolver for the specific handler type

Template Parameters
_HandlerThe handler type
Parameters
handlerThe handler to subscribe

◆ unsubscribe()

template<typename _RawEvent>
void qb::router::semh< _RawEvent, void >::unsubscribe ( _HandlerId const & id)
inlinenoexcept

Unsubscribe a handler by ID.

Parameters
idThe ID of the handler to unsubscribe