LDA++
Public Member Functions | List of all members
ldaplusplus::events::EventDispatcher Class Reference

#include <Events.hpp>

Inheritance diagram for ldaplusplus::events::EventDispatcher:
ldaplusplus::events::EventDispatcherInterface

Public Member Functions

void add_listener (std::shared_ptr< EventListenerInterface > listener) override
 
void remove_listener (std::shared_ptr< EventListenerInterface > listener) override
 
void dispatch (std::shared_ptr< Event > event) override
 
- Public Member Functions inherited from ldaplusplus::events::EventDispatcherInterface
std::shared_ptr< EventListenerInterfaceadd_listener (std::function< void(std::shared_ptr< Event >)> listener)
 
template<class ListenerType , typename... Args>
std::shared_ptr< EventListenerInterfaceadd_listener (Args...args)
 
template<class EventType , typename... Args>
void dispatch (Args...args)
 

Detailed Description

EventDispatcher is a simple implementation of an EventDispatcherInterface. It can be copied, passed by value, reference whatever. It is not thread safe.

Member Function Documentation

void ldaplusplus::events::EventDispatcher::add_listener ( std::shared_ptr< EventListenerInterface listener)
overridevirtual

Add a listener to this dispatcher so that in subsequent calls to dispatch this listener will be notified.

The interface doesn't define handling of double adds or double removes.

Parameters
listenerThe listener to be added

Implements ldaplusplus::events::EventDispatcherInterface.

void ldaplusplus::events::EventDispatcher::dispatch ( std::shared_ptr< Event event)
overridevirtual

Call the on_event() function of every listener passing this event as a parameter.

The interface doesn't define when the on_event function will be called and it is not guaranteed that upon return of the dispatch function all listeners will be notified.

Parameters
eventThe event to be sent to the listeners

Implements ldaplusplus::events::EventDispatcherInterface.

void ldaplusplus::events::EventDispatcher::remove_listener ( std::shared_ptr< EventListenerInterface listener)
overridevirtual

Remove a listener from this dispatcher so that in subsequent calls to dispatch this listener will not be notified.

The interface doesn't define handling of double adds or double removes.

Parameters
listenerThe listener to be removed

Implements ldaplusplus::events::EventDispatcherInterface.


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