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

#include <EventBus.h>

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

Public Member Functions

 EventBus (unsigned int id)
 Constructs an EventBus with a unique identifier.
 
virtual ~EventBus ()
 Destroys the EventBus and cleans up registered entities.
 
unsigned int getId ()
 Gets the unique identifier of this EventBus.
 
void registerKit (IEventBusConnectionKit< T_topic, T_msg, T_data > &connection)
 Registers a connection kit with this EventBus.
 
void unregisterKit (IEventBusConnectionKit< T_topic, T_msg, T_data > &connection)
 Unregisters a connection kit from this EventBus.
 
bool registerEntity (EventEntity< T_topic, T_msg, T_data > *entity)
 Registers an entity (emitter or listener) with this EventBus.
 
void unregisterEntity (EventEntity< T_topic, T_msg, T_data > *entity)
 Unregisters an entity from this EventBus.
 
bool openDataChannel (T_topic topic, size_t limit)
 Opens a data channel for a specific topic with a size limit.
 
bool closeDataChannel (T_topic topic)
 Closes a previously opened data channel.
 
bool sendDataToChannel (T_topic topic, T_data data)
 Sends data to a specific data channel.
 
T_data receiveDataFromChannel (T_topic topic)
 Receives data from a specific data channel.
 
bool isDataChannelEmpty (T_topic topic)
 Checks if a data channel is empty.
 
void emitEvent (T_topic topic, T_msg msg)
 Emits an event to all registered listeners.
 
virtual void execute (short _) override
 Processes all queued events.
 
- Public Member Functions inherited from uniot::IExecutor
virtual ~IExecutor ()
 Virtual destructor for proper cleanup.
 

Friends

class EventEntity< T_topic, T_msg, T_data >
 

Constructor & Destructor Documentation

◆ EventBus()

template<class T_topic, class T_msg, class T_data>
uniot::EventBus< T_topic, T_msg, T_data >::EventBus ( unsigned int id)
inline

Constructs an EventBus with a unique identifier.

Parameters
idUnique identifier for this EventBus

◆ ~EventBus()

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

Destroys the EventBus and cleans up registered entities.

Member Function Documentation

◆ closeDataChannel()

template<class T_topic, class T_msg, class T_data>
bool uniot::EventBus< T_topic, T_msg, T_data >::closeDataChannel ( T_topic topic)

Closes a previously opened data channel.

Parameters
topicThe topic identifier of the channel to close
Return values
trueChannel was closed successfully
falseChannel is not open or already closed

◆ emitEvent()

template<class T_topic, class T_msg, class T_data>
void uniot::EventBus< T_topic, T_msg, T_data >::emitEvent ( T_topic topic,
T_msg msg )

Emits an event to all registered listeners.

Queues an event for processing during the next execute() call.

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

◆ execute()

template<class T_topic, class T_msg, class T_data>
void uniot::EventBus< T_topic, T_msg, T_data >::execute ( short _)
overridevirtual

Processes all queued events.

Distributes all queued events to appropriate listeners. This method should be called regularly from the main application loop.

Parameters
_Unused parameter (inherited from IExecutor)

Implements uniot::IExecutor.

◆ getId()

template<class T_topic, class T_msg, class T_data>
unsigned int uniot::EventBus< T_topic, T_msg, T_data >::getId ( )
inline

Gets the unique identifier of this EventBus.

Return values
idThe identifier assigned to this EventBus

◆ isDataChannelEmpty()

template<class T_topic, class T_msg, class T_data>
bool uniot::EventBus< T_topic, T_msg, T_data >::isDataChannelEmpty ( T_topic topic)

Checks if a data channel is empty.

Parameters
topicThe topic identifier of the channel to check
Return values
trueChannel is empty
falseChannel contains data

◆ openDataChannel()

template<class T_topic, class T_msg, class T_data>
bool uniot::EventBus< T_topic, T_msg, T_data >::openDataChannel ( T_topic topic,
size_t limit )

Opens a data channel for a specific topic with a size limit.

Data channels allow for asynchronous data exchange between components.

Parameters
topicThe topic identifier for the data channel
limitMaximum number of items the channel can hold
Return values
trueChannel was opened successfully
falseChannel is already open or failed to open

◆ receiveDataFromChannel()

template<class T_topic, class T_msg, class T_data>
T_data uniot::EventBus< T_topic, T_msg, T_data >::receiveDataFromChannel ( T_topic topic)

Receives data from a specific data channel.

Parameters
topicThe topic identifier of the channel to receive from
Return values
dataThe received data

◆ registerEntity()

template<class T_topic, class T_msg, class T_data>
bool uniot::EventBus< T_topic, T_msg, T_data >::registerEntity ( EventEntity< T_topic, T_msg, T_data > * entity)

Registers an entity (emitter or listener) with this EventBus.

Parameters
entityThe entity to register
Return values
trueRegistration was successful
falseRegistration failed (e.g., entity already registered)

◆ registerKit()

template<class T_topic, class T_msg, class T_data>
void uniot::EventBus< T_topic, T_msg, T_data >::registerKit ( IEventBusConnectionKit< T_topic, T_msg, T_data > & connection)

Registers a connection kit with this EventBus.

Allows external connection kits to register and interact with this EventBus.

Parameters
connectionThe connection kit to register

◆ sendDataToChannel()

template<class T_topic, class T_msg, class T_data>
bool uniot::EventBus< T_topic, T_msg, T_data >::sendDataToChannel ( T_topic topic,
T_data data )

Sends data to a specific data channel.

Parameters
topicThe topic identifier of the target channel
dataThe data to send
Return values
trueData was successfully sent to the channel
falseChannel is not open or full

◆ unregisterEntity()

template<class T_topic, class T_msg, class T_data>
void uniot::EventBus< T_topic, T_msg, T_data >::unregisterEntity ( EventEntity< T_topic, T_msg, T_data > * entity)

Unregisters an entity from this EventBus.

Parameters
entityThe entity to unregister

◆ unregisterKit()

template<class T_topic, class T_msg, class T_data>
void uniot::EventBus< T_topic, T_msg, T_data >::unregisterKit ( IEventBusConnectionKit< T_topic, T_msg, T_data > & connection)

Unregisters a connection kit from this EventBus.

Parameters
connectionThe connection kit to unregister

Friends And Related Symbol Documentation

◆ EventEntity< T_topic, T_msg, T_data >

template<class T_topic, class T_msg, class T_data>
friend class EventEntity< T_topic, T_msg, T_data >
friend

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