|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Type-safe event loop management. More...
Namespaces | |
| namespace | idfxx |
Classes | |
| class | idfxx::event_base< IdEnum > |
| Typed event base template. More... | |
| struct | idfxx::event_type< IdEnum > |
| Combines an event base with a specific event ID. More... | |
| class | idfxx::event_loop |
| Base class for event loops. More... | |
| class | idfxx::event_loop::listener_handle |
| Handle to a registered event listener. More... | |
| class | idfxx::event_loop::unique_listener_handle |
| RAII handle for event listener registration. More... | |
| class | idfxx::user_event_loop |
| User-created event loop with manual dispatch. More... | |
Macros | |
| #define | IDFXX_EVENT_DEFINE_BASE(name, id_enum) |
| Defines an event base. | |
Typedefs | |
| template<typename IdEnum > | |
| using | idfxx::event_callback = std::move_only_function< void(event_base< IdEnum > base, IdEnum id, void *event_data) const > |
| Callback type for event listeners. | |
Functions | |
| template<typename IdEnum > | |
| idfxx::event_type (event_base< IdEnum >, IdEnum) -> event_type< IdEnum > | |
| constexpr event_type< IdEnum > | idfxx::event_base< IdEnum >::operator() (IdEnum id) const |
| Creates an event_type combining this base with a specific ID. | |
| static std::unique_ptr< user_event_loop > | idfxx::event_loop::make_user (size_t queue_size=32) |
| Creates a user event loop without a dedicated task. | |
| static std::unique_ptr< event_loop > | idfxx::event_loop::make_user (task_config task, size_t queue_size=32) |
| Creates a user event loop with a dedicated dispatch task. | |
| template<typename IdEnum > | |
| listener_handle | idfxx::event_loop::listener_add (event_base< IdEnum > base, IdEnum id, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
| template<typename IdEnum > | |
| listener_handle | idfxx::event_loop::listener_add (event_base< IdEnum > base, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for any event from a base. | |
| template<typename IdEnum > | |
| listener_handle | idfxx::event_loop::listener_add (event_type< IdEnum > event, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
| void | idfxx::event_loop::listener_remove (listener_handle handle) |
| Removes a listener by handle. | |
| template<typename IdEnum > | |
| result< listener_handle > | idfxx::event_loop::try_listener_add (event_base< IdEnum > base, IdEnum id, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
| template<typename IdEnum > | |
| result< listener_handle > | idfxx::event_loop::try_listener_add (event_base< IdEnum > base, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for any event from a base. | |
| template<typename IdEnum > | |
| result< listener_handle > | idfxx::event_loop::try_listener_add (event_type< IdEnum > event, event_callback< std::type_identity_t< IdEnum > > callback) |
| Registers a typed listener for a specific event. | |
Type-safe event loop management.
Provides event loops for posting and subscribing to events with type-safe event bases and IDs.
Depends on Core Utilities for error handling.
| #define IDFXX_EVENT_DEFINE_BASE | ( | name, | |
| id_enum | |||
| ) |
Defines an event base.
Creates an event_base with the given name and enum type. The event base name string is automatically derived from the variable name.
| name | The variable name for the event base. |
| id_enum | The enum class for event IDs within this base. |
| using idfxx::event_callback = typedef std::move_only_function<void(event_base<IdEnum> base, IdEnum id, void* event_data) const> |
| idfxx::event_type | ( | event_base< IdEnum > | , |
| IdEnum | |||
| ) | -> event_type< IdEnum > |
| event_loop::listener_handle idfxx::event_loop::listener_add | ( | event_base< IdEnum > | base, |
| event_callback< std::type_identity_t< IdEnum > > | callback | ||
| ) |
Registers a typed listener for any event from a base.
| IdEnum | The event ID enum type. |
| base | The event base. |
| callback | Function called when any event from this base occurs. Takes ownership of the callback. |
| std::system_error | on failure. |
Definition at line 852 of file event.hpp.
References idfxx::event_loop::try_listener_add(), and idfxx::unwrap().
| event_loop::listener_handle idfxx::event_loop::listener_add | ( | event_base< IdEnum > | base, |
| IdEnum | id, | ||
| event_callback< std::type_identity_t< IdEnum > > | callback | ||
| ) |
Registers a typed listener for a specific event.
| IdEnum | The event ID enum type. |
| base | The event base. |
| id | The specific event ID to listen for. |
| callback | Function called when the event occurs. Takes ownership of the callback. |
| std::system_error | on failure. |
Definition at line 846 of file event.hpp.
References idfxx::event_loop::try_listener_add(), and idfxx::unwrap().
| event_loop::listener_handle idfxx::event_loop::listener_add | ( | event_type< IdEnum > | event, |
| event_callback< std::type_identity_t< IdEnum > > | callback | ||
| ) |
Registers a typed listener for a specific event.
| IdEnum | The event ID enum type. |
| event | The event type (base + id). |
| callback | Function called when the event occurs. Takes ownership of the callback. |
| std::system_error | on failure. |
Definition at line 858 of file event.hpp.
References idfxx::event_loop::try_listener_add(), and idfxx::unwrap().
|
inline |
Removes a listener by handle.
| handle | The listener handle to remove. |
| std::system_error | on failure. |
Definition at line 862 of file event.hpp.
References idfxx::event_loop::try_listener_remove(), and idfxx::unwrap().
|
inlinestatic |
Creates a user event loop without a dedicated task.
Events must be dispatched manually via user_event_loop::run().
| queue_size | Maximum number of events in the queue. |
| std::system_error | on failure. |
Definition at line 834 of file event.hpp.
References idfxx::event_loop::try_make_user().
|
inlinestatic |
Creates a user event loop with a dedicated dispatch task.
The task automatically dispatches events from the queue.
| task | Configuration for the dedicated dispatch task. |
| queue_size | Maximum number of events in the queue. |
| std::system_error | on failure. |
Definition at line 839 of file event.hpp.
References idfxx::event_loop::try_make_user().
|
constexpr |
Creates an event_type combining this base with a specific ID.
| id | The event ID. |
| result< event_loop::listener_handle > idfxx::event_loop::try_listener_add | ( | event_base< IdEnum > | base, |
| event_callback< std::type_identity_t< IdEnum > > | callback | ||
| ) |
Registers a typed listener for any event from a base.
| IdEnum | The event ID enum type. |
| base | The event base. |
| callback | Function called when any event from this base occurs. Takes ownership of the callback. |
Definition at line 890 of file event.hpp.
References idfxx::event_base< IdEnum >::idf_base().
| result< event_loop::listener_handle > idfxx::event_loop::try_listener_add | ( | event_base< IdEnum > | base, |
| IdEnum | id, | ||
| event_callback< std::type_identity_t< IdEnum > > | callback | ||
| ) |
Registers a typed listener for a specific event.
| IdEnum | The event ID enum type. |
| base | The event base. |
| id | The specific event ID to listen for. |
| callback | Function called when the event occurs. Takes ownership of the callback. |
Definition at line 880 of file event.hpp.
References idfxx::event_base< IdEnum >::idf_base().
Referenced by idfxx::event_loop::listener_add(), idfxx::event_loop::listener_add(), idfxx::event_loop::listener_add(), and idfxx::event_loop::try_listener_add().
| result< event_loop::listener_handle > idfxx::event_loop::try_listener_add | ( | event_type< IdEnum > | event, |
| event_callback< std::type_identity_t< IdEnum > > | callback | ||
| ) |
Registers a typed listener for a specific event.
| IdEnum | The event ID enum type. |
| event | The event type (base + id). |
| callback | Function called when the event occurs. Takes ownership of the callback. |
Definition at line 896 of file event.hpp.
References idfxx::event_type< IdEnum >::base, idfxx::event_type< IdEnum >::id, and idfxx::event_loop::try_listener_add().