Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics > Class Template Reference

Zero-heap static topic-based publish/subscribe router. Fans out events to multiple registered delegate subscribers per topic ID without dynamic memory allocation. More...

#include <EventRouter.hpp>

+ Collaboration diagram for corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >:

Public Types

using DelegateType = internal::EventHandlerDelegate< EventVariant, 32 >
 

Public Member Functions

void clear () noexcept
 Reset all topic subscriptions.
 
constexpr EventRouter () noexcept=default
 
size_t publish (uint32_t topicId, const EventVariant &event) const noexcept
 Publish an event variant to all subscribers of a specific topic.
 
template<typename Event >
size_t publishEvent (uint32_t topicId, const Event &event) const noexcept
 Publish a concrete event to all subscribers of a specific topic.
 
bool subscribe (uint32_t topicId, DelegateType subscriber) noexcept
 Subscribe a delegate callback to a specific topic ID.
 
template<typename Event , typename Callable >
bool subscribeEvent (uint32_t topicId, Callable callable) noexcept
 Subscribe a typed event handler lambda to a specific topic ID.
 
size_t topicCount () const noexcept
 Total active topics currently configured.
 

Detailed Description

template<typename EventVariant, size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
class corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >

Zero-heap static topic-based publish/subscribe router. Fans out events to multiple registered delegate subscribers per topic ID without dynamic memory allocation.

Template Parameters
EventVariantVariant containing all supported event types.
MaxSubscribersPerTopicMaximum subscribers registered per topic (default: 8).
MaxTopicsMaximum distinct topics supported (default: 8).

Member Typedef Documentation

◆ DelegateType

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
using corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::DelegateType = internal::EventHandlerDelegate<EventVariant, 32>

Constructor & Destructor Documentation

◆ EventRouter()

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
constexpr corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::EventRouter ( )
constexprdefaultnoexcept

Member Function Documentation

◆ clear()

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
void corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::clear ( )
inlinenoexcept

Reset all topic subscriptions.

◆ publish()

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
size_t corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::publish ( uint32_t  topicId,
const EventVariant &  event 
) const
inlinenoexcept

Publish an event variant to all subscribers of a specific topic.

Parameters
topicIdTarget topic ID.
eventEvent instance to dispatch.
Returns
Number of subscribers invoked.
+ Here is the caller graph for this function:

◆ publishEvent()

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
template<typename Event >
size_t corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::publishEvent ( uint32_t  topicId,
const Event event 
) const
inlinenoexcept

Publish a concrete event to all subscribers of a specific topic.

Template Parameters
EventConcrete event type.
Parameters
topicIdTarget topic ID.
eventEvent instance to dispatch.
Returns
Number of subscribers invoked.
+ Here is the call graph for this function:

◆ subscribe()

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
bool corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::subscribe ( uint32_t  topicId,
DelegateType  subscriber 
)
inlinenoexcept

Subscribe a delegate callback to a specific topic ID.

Parameters
topicIdTopic identifier.
subscriberDelegate callback to execute when an event is published to this topic.
Returns
true if subscriber was registered; false if topic or subscriber slots are full.
+ Here is the caller graph for this function:

◆ subscribeEvent()

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
template<typename Event , typename Callable >
bool corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::subscribeEvent ( uint32_t  topicId,
Callable  callable 
)
inlinenoexcept

Subscribe a typed event handler lambda to a specific topic ID.

Template Parameters
EventConcrete event type to filter on.
CallableLambda/Functor accepting const Event&.
Parameters
topicIdTopic identifier.
callableHandler function.
Returns
true if subscribed successfully.
+ Here is the call graph for this function:

◆ topicCount()

template<typename EventVariant , size_t MaxSubscribersPerTopic = 8, size_t MaxTopics = 8>
size_t corium::EventRouter< EventVariant, MaxSubscribersPerTopic, MaxTopics >::topicCount ( ) const
inlinenoexcept

Total active topics currently configured.


The documentation for this class was generated from the following file: