DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
EventManager Class Reference

Class to centrally manage all events for the application Exposes methods to register subscribers that need to respond to events, and to publish events Dynamically manages a linked list of subscribers to be notified when a relevant event is published Subscribers must extend the EventListener class and implement the onEvent() virtual method provided. More...

#include <EventManager.h>

Collaboration diagram for EventManager:
Collaboration graph
[legend]

Classes

struct  EventSubscriber
 EventSubscriber structure to maintain the linked list of subscribers. More...
 

Public Member Functions

 EventManager ()
 Constructor for the instance.
 
void subscribe (EventListener *eventListener, EventType eventType)
 Method to subscribe a listener to the specified event type.
 
void unsubscribe (EventListener *eventListener, EventType eventType)
 Method to unsubscribe the listener from the specified event type.
 
bool isSubscribed (EventListener *eventListener, EventType eventType)
 Method to check if the specified listener is subscribed to the specified event type.
 
void publish (EventType eventType, EventData eventData)
 Method to publish an event.
 

Private Attributes

EventSubscriber_firstEventSubscriber
 

Detailed Description

Class to centrally manage all events for the application Exposes methods to register subscribers that need to respond to events, and to publish events Dynamically manages a linked list of subscribers to be notified when a relevant event is published Subscribers must extend the EventListener class and implement the onEvent() virtual method provided.

Constructor & Destructor Documentation

◆ EventManager()

EventManager::EventManager ( )

Constructor for the instance.

Member Function Documentation

◆ isSubscribed()

bool EventManager::isSubscribed ( EventListener eventListener,
EventType  eventType 
)

Method to check if the specified listener is subscribed to the specified event type.

Parameters
eventListenerPointer to a class instance that extends the EventListener class
eventTypeValid EventType to check subscription for
Returns
true|false

◆ publish()

void EventManager::publish ( EventType  eventType,
EventData  eventData 
)

Method to publish an event.

Parameters
eventTypeA valid EventType
eventDataValid EventData
Here is the caller graph for this function:

◆ subscribe()

void EventManager::subscribe ( EventListener eventListener,
EventType  eventType 
)

Method to subscribe a listener to the specified event type.

Parameters
eventListerPointer to a class instance that extends the EventListener class
eventTypeValid EventType the subscriber needs to be notified about
Here is the caller graph for this function:

◆ unsubscribe()

void EventManager::unsubscribe ( EventListener eventListener,
EventType  eventType 
)

Method to unsubscribe the listener from the specified event type.

Parameters
eventListenerPointer to a class instance that extends the EventListener class
eventTypeValid EventType to unsubscribe from

Member Data Documentation

◆ _firstEventSubscriber

EventSubscriber* EventManager::_firstEventSubscriber
private

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