Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
hgps::DefaultEventBus Class Referencefinal

Implements the default memory-based simulation event bus type. More...

#include <event_bus.h>

Inheritance diagram for hgps::DefaultEventBus:
[legend]
Collaboration diagram for hgps::DefaultEventBus:
[legend]

Public Member Functions

std::unique_ptr< EventSubscribersubscribe (EventType event_id, std::function< void(std::shared_ptr< EventMessage > message)> &&function) override
 Subscribes a handler function to an event type identifier. More...
 
void publish (std::unique_ptr< EventMessage > message) override
 Publishes a message to all subscribers synchronous. More...
 
void publish_async (std::unique_ptr< EventMessage > message) override
 Publishes a message to all subscribers asynchronous. More...
 
bool unsubscribe (const EventSubscriber &subscriber) override
 Unsubscribes from an event notification. More...
 
std::size_t count ()
 Gets the number of registered subscribers. More...
 
void clear () noexcept
 Clear all registered subscribers. More...
 
- Public Member Functions inherited from hgps::EventAggregator
 EventAggregator ()=default
 Initialises a new instance of the EventAggregator class. More...
 
 EventAggregator (EventAggregator &&other)=default
 Constructs the EventAggregator using move semantics. More...
 
EventAggregatoroperator= (EventAggregator &&other)=default
 Replaces the EventAggregator contents with the other using move semantics. More...
 
 EventAggregator (const EventAggregator &)=delete
 
EventAggregatoroperator= (const EventAggregator &)=delete
 
virtual ~EventAggregator ()=default
 Destroys a EventAggregator instance. More...
 

Detailed Description

Implements the default memory-based simulation event bus type.

Member Function Documentation

◆ clear()

void hgps::DefaultEventBus::clear ( )
noexcept

Clear all registered subscribers.

◆ count()

std::size_t hgps::DefaultEventBus::count ( )

Gets the number of registered subscribers.

Returns
Number of subscribers

◆ publish()

void hgps::DefaultEventBus::publish ( std::unique_ptr< EventMessage message)
overridevirtual

Publishes a message to all subscribers synchronous.

Parameters
messageThe new message instance

Implements hgps::EventAggregator.

Here is the caller graph for this function:

◆ publish_async()

void hgps::DefaultEventBus::publish_async ( std::unique_ptr< EventMessage message)
overridevirtual

Publishes a message to all subscribers asynchronous.

Parameters
messageThe new message instance

Implements hgps::EventAggregator.

Here is the call graph for this function:

◆ subscribe()

std::unique_ptr< EventSubscriber > hgps::DefaultEventBus::subscribe ( EventType  event_id,
std::function< void(std::shared_ptr< EventMessage > message)> &&  handler 
)
overridevirtual

Subscribes a handler function to an event type identifier.

Parameters
event_idThe event type to subscribe
handlerThe event handler function to register
Returns
The event subscriber instance

Implements hgps::EventAggregator.

◆ unsubscribe()

bool hgps::DefaultEventBus::unsubscribe ( const EventSubscriber subscriber)
overridevirtual

Unsubscribes from an event notification.

Parameters
subscriberThe event subscriber instance
Returns
true if the operation succeeded; otherwise, false

Implements hgps::EventAggregator.

Here is the call graph for this function:

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