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

Multiple-Event Single-Handler router. More...

#include <router.h>

Public Types

using _EventId = typename _RawEvent::id_type
using _HandlerId = typename _RawEvent::id_handler_type

Public Member Functions

 mesh (_Handler &handler) noexcept
 Constructs a MESH router with the given handler.
 ~mesh () noexcept
 Destructor that cleans up all event resolvers.
void route (_RawEvent &event)
 Routes an event to the handler.
template<typename _Event>
void subscribe ()
 Subscribe to events of a specific type.
template<typename _Event>
void unsubscribe ()
 Unsubscribe from events of a specific type.
void unsubscribe ()
 Unsubscribe from all event types.

Detailed Description

template<typename _RawEvent, typename _Handler, bool _CleanEvent = true>
class qb::router::mesh< _RawEvent, _Handler, _CleanEvent >

Multiple-Event Single-Handler router.

Routes multiple event types to a single handler based on event type IDs.

Template Parameters
_RawEventThe raw event base type
_HandlerThe handler type
_CleanEventWhether to clean up events after routing

Constructor & Destructor Documentation

◆ mesh()

template<typename _RawEvent, typename _Handler, bool _CleanEvent = true>
qb::router::mesh< _RawEvent, _Handler, _CleanEvent >::mesh ( _Handler & handler)
inlineexplicitnoexcept

Constructs a MESH router with the given handler.

Parameters
handlerThe handler that will receive events

Member Function Documentation

◆ route()

template<typename _RawEvent, typename _Handler, bool _CleanEvent = true>
void qb::router::mesh< _RawEvent, _Handler, _CleanEvent >::route ( _RawEvent & event)
inline

Routes an event to the handler.

Uses the event ID to find the appropriate resolver and process the event.

Parameters
eventThe event to route

◆ subscribe()

template<typename _RawEvent, typename _Handler, bool _CleanEvent = true>
template<typename _Event>
void qb::router::mesh< _RawEvent, _Handler, _CleanEvent >::subscribe ( )
inline

Subscribe to events of a specific type.

Creates and registers an event resolver for the given event type.

Template Parameters
_EventThe event type to subscribe to

◆ unsubscribe() [1/2]

template<typename _RawEvent, typename _Handler, bool _CleanEvent = true>
template<typename _Event>
void qb::router::mesh< _RawEvent, _Handler, _CleanEvent >::unsubscribe ( )
inline

Unsubscribe from events of a specific type.

Removes the event resolver for the given event type.

Template Parameters
_EventThe event type to unsubscribe from

◆ unsubscribe() [2/2]

template<typename _RawEvent, typename _Handler, bool _CleanEvent = true>
void qb::router::mesh< _RawEvent, _Handler, _CleanEvent >::unsubscribe ( )
inline

Unsubscribe from all event types.

Removes all event resolvers.