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

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

#include <router.h>

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

Public Member Functions

template<bool _CleanEvent = true>
void route (_RawEvent &event) noexcept
 Routes an event to the appropriate 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, typename _Handler = void>
class qb::router::semh< _RawEvent, _Handler >

Single-Event Multiple-Handler router (generic version)

Routes a specific event type to multiple handlers based on destination IDs.

Template Parameters
_RawEventThe event type
_HandlerThe handler type (void for heterogeneous handlers)

Member Function Documentation

◆ route()

template<typename _RawEvent, typename _Handler = void>
template<bool _CleanEvent = true>
void qb::router::semh< _RawEvent, _Handler >::route ( _RawEvent & event)
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, typename _Handler = void>
void qb::router::semh< _RawEvent, _Handler >::subscribe ( _Handler & handler)
inlinenoexcept

Subscribe a handler to receive events.

Parameters
handlerThe handler to subscribe

◆ unsubscribe()

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

Unsubscribe a handler by ID.

Parameters
idThe ID of the handler to unsubscribe