LampyEngine
 
Загрузка...
Поиск...
Не найдено
Шаблон класса Event< Args >

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
 
Eventoperator= (const Event &)=delete
 
 Event (Event &&)=delete
 
Eventoperator= (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.

Параметры шаблона
ArgsVariadic 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.

Аргументы
argsArguments to pass to the subscribed handlers.

◆ subscribe()

template<typename... Args>
int Event< Args >::subscribe ( const Handler & handler)
inline

Subscribes a handler to the event.

Аргументы
handlerThe 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.

Аргументы
idThe unique subscription ID of the handler to remove.

Объявления и описания членов класса находятся в файле: