EnTT 3.14.0
|
Utility class to use to send around functions and members. More...
#include <delegate.hpp>
Public Types | |
using | function_type = Ret(const void *, Args...) |
Function type of the contained target. | |
using | type = Ret(Args...) |
Function type of the delegate. | |
using | result_type = Ret |
Return type of the delegate. | |
Public Member Functions | |
delegate () noexcept=default | |
Default constructor. | |
template<auto Candidate, typename... Type> | |
delegate (connect_arg_t< Candidate >, Type &&...value_or_instance) noexcept | |
Constructs a delegate with a given object or payload, if any. | |
delegate (function_type *function, const void *payload=nullptr) noexcept | |
Constructs a delegate and connects an user defined function with optional payload. | |
template<auto Candidate> | |
void | connect () noexcept |
Connects a free function or an unbound member to a delegate. | |
template<auto Candidate, typename Type > | |
void | connect (Type &value_or_instance) noexcept |
Connects a free function with payload or a bound member to a delegate. | |
template<auto Candidate, typename Type > | |
void | connect (Type *value_or_instance) noexcept |
Connects a free function with payload or a bound member to a delegate. | |
void | connect (function_type *function, const void *payload=nullptr) noexcept |
Connects an user defined function with optional payload to a delegate. | |
void | reset () noexcept |
Resets a delegate. | |
function_type * | target () const noexcept |
Returns a pointer to the stored callable function target, if any. | |
const void * | data () const noexcept |
Returns the instance or the payload linked to a delegate, if any. | |
Ret | operator() (Args... args) const |
Triggers a delegate. | |
operator bool () const noexcept | |
Checks whether a delegate actually stores a listener. | |
bool | operator== (const delegate< Ret(Args...)> &other) const noexcept |
Compares the contents of two delegates. | |
Utility class to use to send around functions and members.
Unmanaged delegate for function pointers and members. Users of this class are in charge of disconnecting instances before deleting them.
A delegate can be used as a general purpose invoker without memory overhead for free functions possibly with payloads and bound or unbound members.
Ret | Return type of a function type. |
Args | Types of arguments of a function type. |
Definition at line 66 of file delegate.hpp.
Function type of the contained target.
Definition at line 101 of file delegate.hpp.
Return type of the delegate.
Definition at line 105 of file delegate.hpp.
Function type of the delegate.
Definition at line 103 of file delegate.hpp.
|
inlinenoexcept |
Constructs a delegate with a given object or payload, if any.
Candidate | Function or member to connect to the delegate. |
Type | Type of class or type of payload, if any. |
value_or_instance | Optional valid object that fits the purpose. |
Definition at line 117 of file delegate.hpp.
|
inlinenoexcept |
Constructs a delegate and connects an user defined function with optional payload.
function | Function to connect to the delegate. |
payload | User defined arbitrary data. |
Definition at line 127 of file delegate.hpp.
|
inlinenoexcept |
Connects a free function or an unbound member to a delegate.
Candidate | Function or member to connect to the delegate. |
Definition at line 136 of file delegate.hpp.
|
inlinenoexcept |
Connects an user defined function with optional payload to a delegate.
The delegate isn't responsible for the connected object or the payload. Users must always guarantee that the lifetime of an instance overcomes the one of the delegate.
The payload is returned as the first argument to the target function in all cases.
function | Function to connect to the delegate. |
payload | User defined arbitrary data. |
Definition at line 216 of file delegate.hpp.
|
inlinenoexcept |
Connects a free function with payload or a bound member to a delegate.
The delegate isn't responsible for the connected object or the payload. Users must always guarantee that the lifetime of the instance overcomes the one of the delegate.
When used to connect a free function with payload, its signature must be such that the instance is the first argument before the ones used to define the delegate itself.
Candidate | Function or member to connect to the delegate. |
Type | Type of class or type of payload. |
value_or_instance | A valid reference that fits the purpose. |
Definition at line 166 of file delegate.hpp.
|
inlinenoexcept |
Connects a free function with payload or a bound member to a delegate.
Candidate | Function or member to connect to the delegate. |
Type | Type of class or type of payload. |
value_or_instance | A valid pointer that fits the purpose. |
Definition at line 190 of file delegate.hpp.
|
inlinenoexcept |
Returns the instance or the payload linked to a delegate, if any.
Definition at line 244 of file delegate.hpp.
|
inlineexplicitnoexcept |
Checks whether a delegate actually stores a listener.
Definition at line 269 of file delegate.hpp.
|
inline |
Triggers a delegate.
The delegate invokes the underlying function and returns the result.
args | Arguments to use to invoke the underlying function. |
Definition at line 260 of file delegate.hpp.
|
inlinenoexcept |
Compares the contents of two delegates.
other | Delegate with which to compare. |
Definition at line 279 of file delegate.hpp.
|
inlinenoexcept |
Resets a delegate.
After a reset, a delegate cannot be invoked anymore.
Definition at line 227 of file delegate.hpp.
|
inlinenoexcept |
Returns a pointer to the stored callable function target, if any.
Definition at line 236 of file delegate.hpp.