Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
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.
 
void publish (std::unique_ptr< EventMessage > message) const override
 Publishes a message to all subscribers synchronous.
 
void publish_async (std::unique_ptr< EventMessage > message) const override
 Publishes a message to all subscribers asynchronous.
 
bool unsubscribe (const EventSubscriber &subscriber) override
 Unsubscribes from an event notification.
 
std::size_t count ()
 Gets the number of registered subscribers.
 
void clear () noexcept
 Clear all registered subscribers.
 
- Public Member Functions inherited from hgps::EventAggregator
 EventAggregator ()=default
 Initialises a new instance of the EventAggregator class.
 
 EventAggregator (EventAggregator &&other)=default
 Constructs the EventAggregator using move semantics.
 
EventAggregatoroperator= (EventAggregator &&other)=default
 Replaces the EventAggregator contents with the other using move semantics.
 
 EventAggregator (const EventAggregator &)=delete
 
EventAggregatoroperator= (const EventAggregator &)=delete
 
virtual ~EventAggregator ()=default
 Destroys a EventAggregator instance.
 

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) const
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) const
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: