libnick 2024.12.0
A cross-platform base for native Nickvision applications.
|
An event that can have handlers subscribe to it, which in turn will be called when the event is invoked. More...
#include <event.h>
Public Member Functions | |
Event ()=default | |
Constructs an Event. | |
Event (const Event &e) | |
Constructs an Event via copy. | |
Event (Event &&e) noexcept | |
Constructs an Event via move. | |
size_t | count () const |
Gets the number of handlers subscribed to the event. | |
HandlerId | subscribe (const std::function< void(const T &)> &handler) |
Subscribes a handler to the event. | |
void | unsubscribe (HandlerId id) |
Unsubscribes a handler from the event. | |
void | invoke (const T ¶m) const |
Invokes the event, calling all handlers. | |
HandlerId | operator+= (const std::function< void(const T &)> &handler) |
Subscribes a handler to the event. | |
void | operator-= (HandlerId id) |
Unsubscribes a handler from the event. | |
void | operator() (const T ¶m) |
Invokes the event, calling all handlers. | |
Event & | operator= (const Event &e) |
Copies an Event. | |
Event & | operator= (Event &&e) noexcept |
Moves an Event. | |
operator bool () const | |
Gets whether or not the object is valid or not. | |
An event that can have handlers subscribe to it, which in turn will be called when the event is invoked.
T | Derived type of EventArgs |
|
default |
Constructs an Event.
|
inline |
Constructs an Event via copy.
e | The object to copy |
|
inlinenoexcept |
Constructs an Event via move.
e | The object to move |
|
inline |
Gets the number of handlers subscribed to the event.
|
inline |
Invokes the event, calling all handlers.
param | The parameter to pass to the handlers |
|
inline |
Gets whether or not the object is valid or not.
|
inline |
Invokes the event, calling all handlers.
param | The parameter to pass to the handlers |
|
inline |
Subscribes a handler to the event.
handler | The handler function |
|
inline |
Unsubscribes a handler from the event.
id | The handler id |
|
inline |
|
inlinenoexcept |
|
inline |
Subscribes a handler to the event.
handler | The handler function |
|
inline |
Unsubscribes a handler from the event.
id | The handler id |