#include <delegate.h>

| RESULT | Return value type of the callable. |
Classes | |
| struct | ObjectPointerWrapper |
| struct | PTMFWrapper |
Public Types | |
| using | StubPtrType = RESULT(*)(void *, ARGS...) |
| using | ResultValueType = RESULT |
Public Types inherited from DelegateBase | |
| using | Stub = void(*)() |
Public Member Functions | |
| Delegate ()=default | |
| Delegate (const Delegate &)=delete | |
| Delegate (Delegate &&src)=default | |
| MAXON_IMPLICIT | Delegate (const std::nullptr_t) |
| Delegate (RESULT(*functionPtr)(ARGS...)) | |
| template<typename OBJECT > | |
| Delegate (OBJECT *objectPtr, RESULT(OBJECT::*methodPtr)(ARGS...)) | |
| template<typename OBJECT > | |
| Delegate (const OBJECT *objectPtr, RESULT(OBJECT::*methodPtr)(ARGS...) const) | |
| template<typename OBJECT > | |
| Delegate (OBJECT &object, RESULT(OBJECT::*methodPtr)(ARGS...)) | |
| template<typename OBJECT > | |
| Delegate (const OBJECT &object, RESULT(OBJECT::*methodPtr)(ARGS...) const) | |
| template<typename REF , typename OBJECT > | |
| Delegate (Bool marker, REF &&reference, RESULT(*const &methodPtr)(OBJECT *, ARGS...)) | |
| template<typename FN , typename = typename std::enable_if<!std :: is_convertible<Delegate, typename std::decay<FN>::type>::value && (GetCollectionKind<FN>::value == COLLECTION_KIND::NONE)>::type> | |
| MAXON_IMPLICIT | Delegate (FN &&fn) |
| Delegate & | operator= (const Delegate &)=delete |
| ResultMem | CopyFrom (const Delegate &src) |
| ResultMem | CopyFrom (const std::nullptr_t) |
| ResultMem | CopyFrom (RESULT(*functionPtr)(ARGS...)) |
| template<typename FN , typename = typename std::enable_if<!STD_IS_REPLACEMENT(convertible, Delegate, typename std::decay<FN>::type)>::type> | |
| ResultMem | CopyFrom (FN &&fn) |
| template<typename OBJ > | |
| ResultMem | CopyFrom (OBJ &&object, StubPtrType stub) |
| Delegate & | operator= (Delegate &&)=default |
| Delegate & | operator= (const std::nullptr_t) |
| Delegate & | operator= (RESULT(*const functionPtr)(ARGS...)) |
| template<typename FN , typename = typename std::enable_if<!STD_IS_REPLACEMENT(convertible, Delegate, typename std::decay<FN>::type)>::type> | |
| Delegate & | operator= (FN &&fn) |
| MAXON_ATTRIBUTE_FORCE_INLINE void | Swap (Delegate &other) |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool | operator== (const Delegate &rhs) const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool | operator!= (const Delegate &rhs) const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool | operator< (const Delegate &rhs) const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool | operator== (const std::nullptr_t) const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool | operator!= (const std::nullptr_t) const |
| MAXON_ATTRIBUTE_FORCE_INLINE | operator Bool () const |
| MAXON_ATTRIBUTE_FORCE_INLINE RESULT | operator() (ARGS... args) const |
Public Member Functions inherited from DelegateBase | |
| DelegateBase () | |
| ~DelegateBase () | |
| template<typename STUBPTR > | |
| DelegateBase (void *objectPtr, STUBPTR stubPtr, Callback callback) | |
| template<typename FN , typename STUBPTR > | |
| DelegateBase (FN &&fn, STUBPTR stub, Callback callback) | |
| DelegateBase (const DelegateBase &)=delete | |
| DelegateBase (DelegateBase &&src) | |
| MAXON_OPERATOR_MOVE_ASSIGNMENT (DelegateBase) | |
| void | Reset () |
| ResultMem | CopyFrom (const DelegateBase &src) |
| template<typename FN , typename STUBPTR > | |
| ResultMem | CopyFrom (FN &&f, STUBPTR stub, Callback callback) |
| template<typename OBJ , typename STUBPTR > | |
| ResultMem | CopyFrom (OBJ &&object, STUBPTR stub) |
| Bool | IsEmpty () const |
| Bool | IsPopulated () const |
| Bool | IsStaticFunctionPointer () const |
| template<typename FUNCTIONPTR > | |
| FUNCTIONPTR | GetStaticFunctionPointer () const |
| template<typename STUBPTR > | |
| STUBPTR | GetStubPointer () const |
Static Public Member Functions | |
| static const Delegate & | NullValueRef () |
| template<RESULT(*)(ARGS...) FUNCTION> | |
| static ResultOk< Delegate > | Create () |
| static ResultOk< Delegate > | Create (RESULT(*functionPtr)(ARGS...)) |
| template<typename FN > | |
| static Result< Delegate > | Create (FN &&fn) |
| template<RESULT(*)(ARGS...) FUNCTION> | |
| static Delegate | CreateByReference () |
| static Delegate | CreateByReference (RESULT(*functionPtr)(ARGS...)) |
| template<typename OBJECT , RESULT(OBJECT::*)(ARGS...) METHOD_PTR> | |
| static Delegate | CreateByReference (OBJECT *objectPtr) |
| template<typename OBJECT , RESULT(OBJECT::*)(ARGS...) const METHOD_PTR> | |
| static Delegate | CreateByReference (const OBJECT *objectPtr) |
| template<typename OBJECT , RESULT(OBJECT::*)(ARGS...) METHOD_PTR> | |
| static Delegate | CreateByReference (OBJECT &object) |
| template<typename OBJECT , RESULT(OBJECT::*)(ARGS...) const METHOD_PTR> | |
| static Delegate | CreateByReference (const OBJECT &object) |
| template<typename OBJECT > | |
| static Delegate | CreateByReference (OBJECT *objectPtr, RESULT(OBJECT::*methodPtr)(ARGS...)) |
| template<typename OBJECT > | |
| static Delegate | CreateByReference (const OBJECT *objectPtr, RESULT(OBJECT::*methodPtr)(ARGS...) const) |
| template<typename OBJECT > | |
| static Delegate | CreateByReference (OBJECT &object, RESULT(OBJECT::*methodPtr)(ARGS...)) |
| template<typename OBJECT > | |
| static Delegate | CreateByReference (const OBJECT &object, RESULT(OBJECT::*methodPtr)(ARGS...) const) |
| template<typename FN > | |
| static Delegate | CreateByReference (FN &&fn) |
Private Member Functions | |
| Delegate (void *o, StubPtrType m, Callback c) | |
| template<typename FN > | |
| Delegate & | ConstructFrom (FN &&fn) |
Static Private Member Functions | |
| static StubPtrType | CheckStub (StubPtrType ptr) |
| template<RESULT(*)(ARGS...) FUNCTION> | |
| static MAXON_ATTRIBUTE_FORCE_INLINE RESULT | FunctionStub (void *objectPtr, ARGS... args) |
| template<typename T > | |
| static MAXON_ATTRIBUTE_FORCE_INLINE RESULT | FunctionIndirectStub (void *objectPtr, ARGS... args) |
| template<typename OBJECT , RESULT(OBJECT::*)(ARGS...) METHOD_PTR> | |
| static MAXON_ATTRIBUTE_FORCE_INLINE RESULT | MethodStub (void *objectPtr, ARGS... args) |
| template<typename OBJECT , RESULT(OBJECT::*)(ARGS...) const METHOD_PTR> | |
| static MAXON_ATTRIBUTE_FORCE_INLINE RESULT | ConstMethodStub (void *objectPtr, ARGS... args) |
| template<typename T > | |
| static MAXON_ATTRIBUTE_FORCE_INLINE RESULT | FunctorStub (void *objectPtr, ARGS... args) |
| using StubPtrType = RESULT (*)(void*, ARGS...) |
| using ResultValueType = RESULT |
|
private |
|
default |
| MAXON_IMPLICIT Delegate | ( | const std::nullptr_t | ) |
|
explicit |
Constructs a delegate for a function pointer. This is less efficient than Delegate::Create<METHODE_NAME>() because it requires an extra indirect function pointer jump (the method can't be inlined).
| Delegate | ( | OBJECT * | objectPtr, |
| RESULT(OBJECT::*)(ARGS...) | methodPtr | ||
| ) |
Constructs a delegate for a virtual member function of an object.
| OBJECT | The object type. |
| [in] | objectPtr | Self pointer of the object. |
| [in] | methodPtr | Pointer to the member function. |
| Delegate | ( | const OBJECT * | objectPtr, |
| RESULT(OBJECT::*)(ARGS...) const | methodPtr | ||
| ) |
Constructs a delegate for a const virtual member function of an object.
| OBJECT | The object type. |
| [in] | objectPtr | Self pointer of the object. |
| [in] | methodPtr | Pointer to the const member function. |
| Delegate | ( | OBJECT & | object, |
| RESULT(OBJECT::*)(ARGS...) | methodPtr | ||
| ) |
Constructs a delegate for a virtual member function of an object.
| OBJECT | The object type. |
| [in] | object | Reference of the object. |
| [in] | methodPtr | Pointer to the member function. |
| Delegate | ( | const OBJECT & | object, |
| RESULT(OBJECT::*)(ARGS...) const | methodPtr | ||
| ) |
Constructs a delegate for a const virtual member function of a const object.
| OBJECT | The object type. |
| [in] | object | Reference of the const object. |
| [in] | methodPtr | Pointer to the const member function. |
| MAXON_IMPLICIT Delegate | ( | FN && | fn | ) |
Constructs a delegate when T is not a Delegate, but a function pointer, ptmf or a PTMFWrapper<OBJECT*, RESULT (OBJECT::*)(ARGS...)>.
|
staticprivate |
|
static |
A delegate cannot be copied without error checks because this might involve memory allocations.
Copies a delegate.
| [in] | src | Source delegate. |
| ResultMem CopyFrom | ( | const std::nullptr_t | ) |
Resets the delegate.
| ResultMem CopyFrom | ( | RESULT(*)(ARGS...) | functionPtr | ) |
Copies the function pointer.
| [in] | functionPtr | Static function pointer |
| ResultMem CopyFrom | ( | FN && | fn | ) |
Copies or moves fn into the Delegate and allocates memory if necessary.
| FN | The callable type. |
| [in] | fn | Callable. |
| ResultMem CopyFrom | ( | OBJ && | object, |
| StubPtrType | stub | ||
| ) |
Copies or moves object into the Delegate and sets #stub as the handler for delegate calls. #stub will receive a pointer to the object held by the Delegate in its first parameter.
| OBJ | The object type. |
| [in] | object | The object to move or copy. |
| [in] | stub | The call handler. |
| Delegate& operator= | ( | const std::nullptr_t | ) |
| Delegate& operator= | ( | RESULT(*)(ARGS...) | functionPtr | ) |
| Delegate& operator= | ( | FN && | fn | ) |
Assign when T is not a Delegate, but a function pointer, ptmf or a PTMFWrapper<OBJECT*, RESULT (OBJECT::*)(ARGS...)>.
Returns a delegate for a static member function (direct call). This is the most efficient delegate because the stub can inline the function (or at least make a direct jump).
Returns delegate for a function pointer. Less efficient than using Delegate::Create<T>() because this requires an extra indirect function pointer jump.
Returns a delegate for an object with a callable, usually a lambda. The object is copied (or moved if possible). If the allocation fails an error is returned.
| FN | The callable object type. |
| [in] | fn | Callable. |
|
static |
Returns a delegate for a static member function (direct call). This is the most efficient delegate because the stub can inline the function (or at least make a direct jump).
|
static |
Returns delegate for a function pointer. Less efficient than using Delegate::Create<T>() because this requires an extra indirect function pointer jump.
|
static |
Returns a delegate for a virtual member function.
| OBJECT | The object type. |
| METHOD_PTR | The virtual member function type (which can be resolved to a specific function pointer). |
| [in] | objectPtr | Self pointer of the object. |
|
static |
Returns a delegate for a const virtual member function.
| OBJECT | The object type. |
| METHOD_PTR | The const virtual member function type (which can be resolved to a specific function pointer). |
| [in] | objectPtr | Self pointer of the object. |
|
static |
Returns a delegate for a virtual member function.
| OBJECT | The object type. |
| METHOD_PTR | The virtual member function type (which can be resolved to a specific function pointer). |
| [in] | object | Reference of the object. |
|
static |
Returns a delegate for a const virtual member function.
| OBJECT | The object type. |
| METHOD_PTR | The virtual member function type (which can be resolved to a specific function pointer). |
| [in] | object | Reference of the object. |
|
static |
Returns a delegate for a virtual member function.
| OBJECT | The object type. |
| [in] | objectPtr | Self pointer of the object. |
| [in] | methodPtr | Pointer to the member function. |
|
static |
Returns a delegate for a const virtual member function.
| OBJECT | The object type. |
| [in] | objectPtr | Self pointer of the object. |
| [in] | methodPtr | Pointer to the const member function. |
|
static |
Returns a delegate for a virtual member function.
| OBJECT | The object type. |
| [in] | object | Reference of the object. |
| [in] | methodPtr | Pointer to the member function. |
|
static |
Returns a delegate for a const virtual member function.
| OBJECT | The object type. |
| [in] | object | Reference of the const object. |
| [in] | methodPtr | Pointer to the const member function. |
|
static |
| MAXON_ATTRIBUTE_FORCE_INLINE void Swap | ( | Delegate< RESULT(ARGS...)> & | other | ) |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool operator== | ( | const Delegate< RESULT(ARGS...)> & | rhs | ) | const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool operator!= | ( | const Delegate< RESULT(ARGS...)> & | rhs | ) | const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool operator< | ( | const Delegate< RESULT(ARGS...)> & | rhs | ) | const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool operator== | ( | const std::nullptr_t | ) | const |
| MAXON_ATTRIBUTE_FORCE_INLINE Bool operator!= | ( | const std::nullptr_t | ) | const |
|
explicit |
| MAXON_ATTRIBUTE_FORCE_INLINE RESULT operator() | ( | ARGS... | args | ) | const |
Forwards the call (invokes the stub function for a callable).
|
private |
Constructs the delegate when T is not a Delegate, but a function pointer, ptmf or a PTMFWrapper<OBJECT*, RESULT (OBJECT::*)(ARGS...)>.
|
staticprivate |
Invokes a C style function via direct call (inlines it if possible).
|
staticprivate |
Invokes a C style function via indirect function pointer call.
|
staticprivate |
Invokes a virtual member function.
|
staticprivate |
Invokes a const virtual member function.
|
staticprivate |