![]() |
|
Uniot Core
|
| 0.8.1 |
#include <EventBus.h>
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 > |
|
inline |
|
virtual |
Destroys the EventBus and cleans up registered entities.
| bool uniot::EventBus< T_topic, T_msg, T_data >::closeDataChannel | ( | T_topic | topic | ) |
Closes a previously opened data channel.
| topic | The topic identifier of the channel to close |
| true | Channel was closed successfully |
| false | Channel is not open or already closed |
| 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.
| topic | The topic identifier of the event |
| msg | The message payload of the event |
|
overridevirtual |
Processes all queued events.
Distributes all queued events to appropriate listeners. This method should be called regularly from the main application loop.
| _ | Unused parameter (inherited from IExecutor) |
Implements uniot::IExecutor.
|
inline |
| bool uniot::EventBus< T_topic, T_msg, T_data >::isDataChannelEmpty | ( | T_topic | topic | ) |
Checks if a data channel is empty.
| topic | The topic identifier of the channel to check |
| true | Channel is empty |
| false | Channel contains 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.
| topic | The topic identifier for the data channel |
| limit | Maximum number of items the channel can hold |
| true | Channel was opened successfully |
| false | Channel is already open or failed to open |
| T_data uniot::EventBus< T_topic, T_msg, T_data >::receiveDataFromChannel | ( | T_topic | topic | ) |
Receives data from a specific data channel.
| topic | The topic identifier of the channel to receive from |
| data | The received 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.
| entity | The entity to register |
| true | Registration was successful |
| false | Registration failed (e.g., entity already registered) |
| void uniot::EventBus< T_topic, T_msg, T_data >::registerKit | ( | IEventBusConnectionKit< T_topic, T_msg, T_data > & | connection | ) |
| bool uniot::EventBus< T_topic, T_msg, T_data >::sendDataToChannel | ( | T_topic | topic, |
| T_data | data ) |
Sends data to a specific data channel.
| topic | The topic identifier of the target channel |
| data | The data to send |
| true | Data was successfully sent to the channel |
| false | Channel is not open or full |
| void uniot::EventBus< T_topic, T_msg, T_data >::unregisterEntity | ( | EventEntity< T_topic, T_msg, T_data > * | entity | ) |
Unregisters an entity from this EventBus.
| entity | The entity to unregister |
| 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.
| connection | The connection kit to unregister |
|
friend |