Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::EventListener< T_topic, T_msg, T_data > Class Template Referenceabstract

#include <EventListener.h>

Inheritance diagram for uniot::EventListener< T_topic, T_msg, T_data >:
[legend]

Public Member Functions

virtual ~EventListener ()=default
 Virtual destructor.
 
virtual type_id getTypeId () const override
 Get the type ID of this class for RTTI.
 
EventListenerlistenToEvent (T_topic topic)
 Subscribe to events of a specific topic.
 
EventListenerstopListeningToEvent (T_topic topic)
 Unsubscribe from events of a specific topic.
 
bool isListeningToEvent (T_topic topic)
 Check if this listener is subscribed to a specific topic.
 
virtual void onEventReceived (T_topic topic, T_msg msg)=0
 Handler called when an event is received.
 
- Public Member Functions inherited from uniot::EventEmitter< T_topic, T_msg, T_data >
virtual ~EventEmitter ()=default
 Virtual destructor to ensure proper cleanup of derived classes.
 
void emitEvent (T_topic topic, T_msg msg)
 Emits an event to all registered event buses.
 
- Public Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data >
virtual ~EventEntity ()
 Destructor - disconnects from all connected EventBus instances.
 
bool sendDataToChannel (T_topic channel, T_data data)
 Sends data to a specific channel on all connected EventBus instances.
 
void receiveDataFromChannel (T_topic channel, DataChannelCallback callback)
 Receives data from a specific channel on all connected EventBus instances.
 

Additional Inherited Members

- Public Types inherited from uniot::EventEntity< T_topic, T_msg, T_data >
using DataChannelCallback = std::function<void(unsigned int, bool, T_data)>
 Callback type for handling data received from channels.
 
- Protected Member Functions inherited from uniot::EventEntity< T_topic, T_msg, T_data >
bool connectUnique (EventBus< T_topic, T_msg, T_data > *eventBus)
 Connects to an EventBus instance if not already connected.
 
- Protected Attributes inherited from uniot::EventEntity< T_topic, T_msg, T_data >
IterableQueue< EventBus< T_topic, T_msg, T_data > * > mEventBusQueue
 Queue of EventBus instances this entity is connected to.
 

Constructor & Destructor Documentation

◆ ~EventListener()

template<class T_topic, class T_msg, class T_data>
virtual uniot::EventListener< T_topic, T_msg, T_data >::~EventListener ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ getTypeId()

template<class T_topic, class T_msg, class T_data>
virtual type_id uniot::EventListener< T_topic, T_msg, T_data >::getTypeId ( ) const
inlineoverridevirtual

Get the type ID of this class for RTTI.

Return values
type_idThe unique type identifier for this EventListener specialization

Reimplemented from uniot::EventEmitter< T_topic, T_msg, T_data >.

◆ isListeningToEvent()

template<class T_topic, class T_msg, class T_data>
bool uniot::EventListener< T_topic, T_msg, T_data >::isListeningToEvent ( T_topic topic)

Check if this listener is subscribed to a specific topic.

Parameters
topicThe topic to check
Return values
trueThe listener is subscribed to the topic
falseThe listener is not subscribed to the topic

◆ listenToEvent()

template<class T_topic, class T_msg, class T_data>
EventListener< T_topic, T_msg, T_data > * uniot::EventListener< T_topic, T_msg, T_data >::listenToEvent ( T_topic topic)

Subscribe to events of a specific topic.

Parameters
topicThe topic to listen to
Return values
EventListener*Pointer to this instance for method chaining

◆ onEventReceived()

template<class T_topic, class T_msg, class T_data>
virtual void uniot::EventListener< T_topic, T_msg, T_data >::onEventReceived ( T_topic topic,
T_msg msg )
pure virtual

Handler called when an event is received.

This method must be implemented by derived classes to handle incoming events for topics that this listener has subscribed to.

Parameters
topicThe topic of the received event
msgThe message payload of the received event

Implemented in uniot::CallbackEventListener< T_topic, T_msg, T_data >, uniot::CallbackEventListener< unsigned int, int, Bytes >, uniot::LispDevice, uniot::MQTTKit, uniot::NetworkController, and uniot::unLisp.

◆ stopListeningToEvent()

template<class T_topic, class T_msg, class T_data>
EventListener< T_topic, T_msg, T_data > * uniot::EventListener< T_topic, T_msg, T_data >::stopListeningToEvent ( T_topic topic)

Unsubscribe from events of a specific topic.

Parameters
topicThe topic to stop listening to
Return values
EventListener*Pointer to this instance for method chaining

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