![]() |
|
Uniot Core
|
| 0.8.1 |
Entity that can connect to and interact with EventBus instances. More...
#include <EventEntity.h>
Public Types | |
| using | DataChannelCallback = std::function<void(unsigned int, bool, T_data)> |
| Callback type for handling data received from channels. | |
Public Member Functions | |
| virtual | ~EventEntity () |
| Destructor - disconnects from all connected EventBus instances. | |
| virtual type_id | getTypeId () const override |
| Returns the type ID of this class. | |
| 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. | |
Protected Member Functions | |
| bool | connectUnique (EventBus< T_topic, T_msg, T_data > *eventBus) |
| Connects to an EventBus instance if not already connected. | |
Protected Attributes | |
| IterableQueue< EventBus< T_topic, T_msg, T_data > * > | mEventBusQueue |
| Queue of EventBus instances this entity is connected to. | |
Friends | |
| class | EventBus< T_topic, T_msg, T_data > |
Entity that can connect to and interact with EventBus instances.
EventEntity serves as a base class for components that need to communicate through the event system. It can connect to multiple EventBus instances and provides methods for sending and receiving data through channels.
| using uniot::EventEntity< T_topic, T_msg, T_data >::DataChannelCallback = std::function<void(unsigned int, bool, T_data)> |
Callback type for handling data received from channels.
| unsigned | int EventBus ID |
| bool | Whether the channel was empty before receiving |
| T_data | The data received from the channel |
|
virtual |
|
inlineprotected |
Connects to an EventBus instance if not already connected.
Checks if the EventBus with the same ID is already connected. If not, adds it to the queue of connected EventBus instances.
| eventBus | Pointer to the EventBus to connect to |
| true | Connection was successful |
| false | Connection failed (e.g., EventBus already connected) |
|
inlineoverridevirtual |
Returns the type ID of this class.
Implementation of IWithType interface method.
| type_id | The unique type identifier for this class |
Implements uniot::IWithType.
Reimplemented in uniot::EventEmitter< T_topic, T_msg, T_data >, uniot::EventEmitter< unsigned int, int, Bytes >, uniot::EventEmitter< unsigned int, int, Bytes >, uniot::EventListener< T_topic, T_msg, T_data >, uniot::EventListener< unsigned int, int, Bytes >, and uniot::EventListener< unsigned int, int, Bytes >.
|
inline |
Receives data from a specific channel on all connected EventBus instances.
Iterates through all connected EventBus instances and retrieves data from the specified channel on each, invoking the callback for each data item.
| channel | The channel to receive data from |
| callback | Function to be called for each data item received |
|
inline |
|
friend |
|
protected |