|
LiteFX 0.5.1.2025
Computer Graphics Engine
|
Represents a handler for an Event, that is assigned a unique token when created, so that it can be identified later. More...
#include <app.hpp>
Public Types | |
| using | function_type = std::function<TResult(TArgs...)> |
| using | token_type = size_t |
Public Member Functions | |
| Delegate (function_type fn, token_type t) noexcept | |
| Creates a new delegate. | |
| TResult | invoke (TArgs... args) const |
| Invokes the delegate function. | |
| token_type | token () const |
| Returns the unique token of the delegate. | |
| TResult | operator() (TArgs... args) const |
| Invokes the delegate function. | |
Represents a handler for an Event, that is assigned a unique token when created, so that it can be identified later.
Since a std::function or callable is non-comparable, it is not possible to identify and remove event handlers from an event, after registering them. To support this functionality, the event handler will be encapsulated in a delegate, which gets assigned with a token. This token is unique for the event, the delegate has been registered to.
| TResult | The result of the delegate function. |
| ...TArgs | The arguments of the delegate function. |
| using LiteFX::Delegate< TResult, TArgs >::function_type = std::function<TResult(TArgs...)> |
| using LiteFX::Delegate< TResult, TArgs >::token_type = size_t |
|
inlinenoexcept |
Creates a new delegate.
| fn | The delegate function. |
| t | The unique token of the delegate within the parent event. |
|
inline |
Invokes the delegate function.
| ...args | The arguments passed to the function. |
|
inline |
Invokes the delegate function.
| ...args | The arguments passed to the function. |
|
inline |
Returns the unique token of the delegate.