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

#include <CallbackEventListener.h>

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

Public Types

using EventListenerCallback = std::function<void(T_topic, T_msg)>
 Callback function type for event handling.
 
- 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.
 

Public Member Functions

 CallbackEventListener (EventListenerCallback callback)
 Constructs a CallbackEventListener with the given callback function.
 
virtual void onEventReceived (T_topic topic, T_msg msg)
 Handler called when an event is received.
 
- Public Member Functions inherited from uniot::EventListener< T_topic, T_msg, T_data >
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.
 
- 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

- 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.
 

Member Typedef Documentation

◆ EventListenerCallback

template<class T_topic, class T_msg, class T_data>
using uniot::CallbackEventListener< T_topic, T_msg, T_data >::EventListenerCallback = std::function<void(T_topic, T_msg)>

Callback function type for event handling.

This function will be called when an event is received with the topic and message as parameters.

Constructor & Destructor Documentation

◆ CallbackEventListener()

template<class T_topic, class T_msg, class T_data>
uniot::CallbackEventListener< T_topic, T_msg, T_data >::CallbackEventListener ( EventListenerCallback callback)

Constructs a CallbackEventListener with the given callback function.

Parameters
callbackThe function to call when an event is received.

Member Function Documentation

◆ onEventReceived()

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

Handler called when an event is received.

This overrides the base EventListener method and invokes the stored callback.

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

Implements uniot::EventListener< T_topic, T_msg, T_data >.


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