A thread-safe, generic event system that allows subscribing, unsubscribing, and invoking event handlers.
Подробнее...
#include <Event.h>
|
using | Handler = std::function<void(Args...)> |
| Defines a function type for event handlers.
|
|
|
| Event (const Event &)=delete |
|
Event & | operator= (const Event &)=delete |
|
| Event (Event &&)=delete |
|
Event & | operator= (Event &&)=delete |
|
int | subscribe (const Handler &handler) |
| Subscribes a handler to the event.
|
|
void | unsubscribe (int id) |
| Unsubscribes a handler using its subscription ID.
|
|
void | operator() (Args... args) |
| Invokes all subscribed handlers with the provided arguments.
|
|
template<typename... Args>
class Event< Args >
A thread-safe, generic event system that allows subscribing, unsubscribing, and invoking event handlers.
- Параметры шаблона
-
Args | Variadic template parameters representing the event's argument types. |
◆ operator()()
template<typename... Args>
void Event< Args >::operator() |
( |
Args... | args | ) |
|
|
inline |
Invokes all subscribed handlers with the provided arguments.
- Аргументы
-
args | Arguments to pass to the subscribed handlers. |
◆ subscribe()
template<typename... Args>
Subscribes a handler to the event.
- Аргументы
-
handler | The function to be called when the event is triggered. |
- Возвращает
- A unique subscription ID for the handler.
◆ unsubscribe()
template<typename... Args>
void Event< Args >::unsubscribe |
( |
int | id | ) |
|
|
inline |
Unsubscribes a handler using its subscription ID.
- Аргументы
-
id | The unique subscription ID of the handler to remove. |
Объявления и описания членов класса находятся в файле: