MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Delegates Namespace Reference

Namespaces

namespace  Detail
 

Data Structures

struct  TDynamicMethodPtr_Struct
 
struct  TDynamicMethodPtr_Struct< Dynamic >
 
struct  TDynamicSignature_Struct
 
struct  TDynamicSignature_Struct< Dynamic >
 
class  TEventDelegate
 
class  TEventDelegate< void(Args...), DefaultInvokeMode >
 
class  TEventMultiplex
 
class  TEventMultiplex< Return(Args...)>
 
class  TEventMultiplex< void(Args...)>
 
struct  TNative_Struct
 
struct  TNative_Struct< Dynamic >
 
struct  TNativeEvent_Struct
 
struct  TNativeMultiplex_Struct
 
struct  TReturnOverride_Struct
 

Concepts

concept  CDynamicDelegate
 
concept  CDynamicMulticastDelegate
 

Typedefs

template<CFunctionLike Function, typename... Captures>
using TInferredDelegate
 
template<typename Signature , int32 Flags = 0>
using TRetainingEventDelegate = TEventDelegate<Signature, CopyArguments | Flags>
 
template<typename Signature , int32 Flags = 0>
using TBelatedEventDelegate = TEventDelegate<Signature, BelatedInvoke | Flags>
 
template<typename Signature , int32 Flags = 0>
using TBelatedRetainingEventDelegate = TEventDelegate<Signature, BelatedInvoke | CopyArguments | Flags>
 
template<typename Signature , int32 Flags = 0>
using TOneTimeEventDelegate = TEventDelegate<Signature, InvokeOnce | Flags>
 
template<typename Signature , int32 Flags = 0>
using TOneTimeRetainingEventDelegate = TEventDelegate<Signature, InvokeOnce | CopyArguments | Flags>
 
template<typename Signature , int32 Flags = 0>
using TOneTimeBelatedEventDelegate = TEventDelegate<Signature, InvokeOnce | BelatedInvoke | Flags>
 
template<typename Signature , int32 Flags = 0>
using TOneTimeRetainingBelatedEventDelegate
 
template<typename Dynamic , int32 DefaultSettings = DefaultInvocation>
using TNativeEvent = typename TNativeEvent_Struct<Dynamic, DefaultSettings>::Type
 
template<typename Dynamic >
using TReturnOverride = typename TReturnOverride_Struct<Dynamic>::Type
 
template<typename Dynamic , typename Return = TReturnOverride<Dynamic>>
using TNativeMultiplex = typename TNativeMultiplex_Struct<Dynamic, Return>::Type
 
template<typename Dynamic >
using TDynamicMethodPtr = typename TDynamicMethodPtr_Struct<std::decay_t<Dynamic>>::Type
 
template<typename Dynamic >
using TDynamicSignature = typename TDynamicSignature_Struct<std::decay_t<Dynamic>>::Type
 
template<typename Dynamic >
using TNative = typename TNative_Struct<std::decay_t<Dynamic>>::Type
 

Enumerations

enum  EInvokeMode {
  DefaultInvocation = 0 , InvokeOnce = 1 << 0 , BelatedInvoke = 1 << 1 , CopyArguments = 1 << 2 ,
  ThreadSafeEvent = 1 << 3
}
 

Functions

template<CDynamicDelegate Dynamic, typename MethodPtrTypeDynamic = TDynamicMethodPtr<Dynamic>, typename NativeDelegateType = TDelegate<TFunction_Signature<MethodPtrTypeDynamic>>, typename MethodPtrTypeNative = typename TMemFunPtrType< false, FDeclareOnly, typename NativeDelegateType::TFuncType >::Type>
requires CSameAs<MethodPtrTypeDynamic, MethodPtrTypeNative>
NativeDelegateType AsNative (Dynamic &&dynamicDelegate)
 
template<CFunctionLike Function, typename... Captures>
requires (!TFunction_IsMember<Function>) && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > From (Function func, const Captures &... captures)
 
template<CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > From (Function &&func)
 
template<CSharedRef Object, CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > From (const Object &self, Function &&func)
 
template<CSharedFromThis Object, CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > From (Object *self, Function &&func)
 
template<CSharedFromThis Object, CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > From (const Object *self, Function &&func)
 
template<CPlainClass Object, CFunctionLike Function, typename... Captures>
requires TFunction_IsMember<Function> && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > From (Object *self, Function func, const Captures &... captures)
 
template<CPlainClass Object, CFunctionLike Function, typename... Captures>
requires TFunction_IsMember<Function> && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > From (const Object *self, Function func, const Captures &... captures)
 
template<CSharedRef Object, CFunctionLike Function, typename... Captures>
requires TFunction_IsMember<Function> && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > From (const Object &self, Function func, const Captures &... captures)
 
template<typename... Args>
TDelegate< void(Args...)> From (TMulticastDelegate< void(Args...)> &multicast)
 
template<typename Object , typename... Args>
TDelegate< void(Args...)> From (Object &&self, TMulticastDelegate< void(Args...)> &multicast)
 
template<CDynamicMulticastDelegate Dynamic>
TNative< typename Dynamic::FDelegate > From (Dynamic &multicast)
 
template<typename Object , CDynamicMulticastDelegate Dynamic>
TNative< typename Dynamic::FDelegate > From (Object &&self, Dynamic &multicast)
 

Typedef Documentation

◆ TBelatedEventDelegate

template<typename Signature , int32 Flags = 0>
using Mcro::Delegates::TBelatedEventDelegate = TEventDelegate<Signature, BelatedInvoke | Flags>

Definition at line 344 of file EventDelegate.h.

◆ TBelatedRetainingEventDelegate

template<typename Signature , int32 Flags = 0>
using Mcro::Delegates::TBelatedRetainingEventDelegate = TEventDelegate<Signature, BelatedInvoke | CopyArguments | Flags>

Definition at line 347 of file EventDelegate.h.

◆ TDynamicMethodPtr

template<typename Dynamic >
using Mcro::Delegates::TDynamicMethodPtr = typename TDynamicMethodPtr_Struct<std::decay_t<Dynamic>>::Type

Get the native function pointer type compatible with given dynamic (multicast) delegate

Definition at line 55 of file Traits.h.

◆ TDynamicSignature

template<typename Dynamic >
using Mcro::Delegates::TDynamicSignature = typename TDynamicSignature_Struct<std::decay_t<Dynamic>>::Type

Get the native function signature type compatible with given dynamic (multicast) delegate

Definition at line 76 of file Traits.h.

◆ TInferredDelegate

template<CFunctionLike Function, typename... Captures>
using Mcro::Delegates::TInferredDelegate
Initial value:
TDelegate<
TFunction_Return<Function>,
TTrimEnd<sizeof...(Captures), typename TFunction<Function>::Arguments>
>,
FDefaultDelegateUserPolicy
>
typename TFunctionFromTuple_Struct< std::decay_t< Return >, std::decay_t< Tuple > >::Type TFunctionFromTuple
typename TTrimEnd_Struct< Count, Tuple >::Type TTrimEnd
Definition Tuples.h:55

Definition at line 44 of file DelegateFrom.h.

◆ TNative

template<typename Dynamic >
using Mcro::Delegates::TNative = typename TNative_Struct<std::decay_t<Dynamic>>::Type

Map the input dynamic (multicast) delegate to a conceptually compatible native (multicast) delegate type

Definition at line 97 of file Traits.h.

◆ TNativeEvent

template<typename Dynamic , int32 DefaultSettings = DefaultInvocation>
using Mcro::Delegates::TNativeEvent = typename TNativeEvent_Struct<Dynamic, DefaultSettings>::Type

Map the input dynamic multicast delegate to a conceptually compatible native event delegate type

Definition at line 372 of file EventDelegate.h.

◆ TNativeMultiplex

template<typename Dynamic , typename Return = TReturnOverride<Dynamic>>
using Mcro::Delegates::TNativeMultiplex = typename TNativeMultiplex_Struct<Dynamic, Return>::Type

Definition at line 159 of file EventMultiplex.h.

◆ TOneTimeBelatedEventDelegate

template<typename Signature , int32 Flags = 0>
using Mcro::Delegates::TOneTimeBelatedEventDelegate = TEventDelegate<Signature, InvokeOnce | BelatedInvoke | Flags>

Definition at line 356 of file EventDelegate.h.

◆ TOneTimeEventDelegate

template<typename Signature , int32 Flags = 0>
using Mcro::Delegates::TOneTimeEventDelegate = TEventDelegate<Signature, InvokeOnce | Flags>

Definition at line 350 of file EventDelegate.h.

◆ TOneTimeRetainingBelatedEventDelegate

template<typename Signature , int32 Flags = 0>
using Mcro::Delegates::TOneTimeRetainingBelatedEventDelegate
Initial value:
TEventDelegate<Signature,
>

Definition at line 359 of file EventDelegate.h.

◆ TOneTimeRetainingEventDelegate

template<typename Signature , int32 Flags = 0>
using Mcro::Delegates::TOneTimeRetainingEventDelegate = TEventDelegate<Signature, InvokeOnce | CopyArguments | Flags>

Definition at line 353 of file EventDelegate.h.

◆ TRetainingEventDelegate

template<typename Signature , int32 Flags = 0>
using Mcro::Delegates::TRetainingEventDelegate = TEventDelegate<Signature, CopyArguments | Flags>

Definition at line 341 of file EventDelegate.h.

◆ TReturnOverride

template<typename Dynamic >
using Mcro::Delegates::TReturnOverride = typename TReturnOverride_Struct<Dynamic>::Type

Definition at line 142 of file EventMultiplex.h.

Enumeration Type Documentation

◆ EInvokeMode

Settings for the TEventDelegate class, which defines optional behavior when adding a binding to it

Enumerator
DefaultInvocation 

The event delegate will act the same as a TMulticastDelegate

InvokeOnce 1 << 0 

The binding will be automatically removed after the next broadcast

BelatedInvoke 1 << 1 

The binding will be executed immediately if the delegate has already been broadcasted

CopyArguments 1 << 2 

Attempt to copy arguments when storing them for belated invokes, instead of perfect forwarding them. This is only considered from the template argument

ThreadSafeEvent 1 << 3 

Enable mutex locks around adding/broadcasting delegates. Only considered in DefaultInvokeMode

Definition at line 26 of file EventDelegate.h.

Function Documentation

◆ AsNative()

template<CDynamicDelegate Dynamic, typename MethodPtrTypeDynamic = TDynamicMethodPtr<Dynamic>, typename NativeDelegateType = TDelegate<TFunction_Signature<MethodPtrTypeDynamic>>, typename MethodPtrTypeNative = typename TMemFunPtrType< false, FDeclareOnly, typename NativeDelegateType::TFuncType >::Type>
requires CSameAs<MethodPtrTypeDynamic, MethodPtrTypeNative>
NativeDelegateType Mcro::Delegates::AsNative ( Dynamic && dynamicDelegate)

Creates a native delegate that is bound to the same UFunction as the specified dynamic delegate.

Note
This function can only convert non-multicast delegates.

The signatures of the functions are checked, so that it is not possible to compile a conversion that would crash at runtime.

Example Usage:

using FMyNativeDelegate = TDelegate<void(int32 someParam)>;
DECLARE_DYNAMIC_DELEGATE_OneParam(FMyBlueprintDelegate, const int32, someParam);

void MyNativeDelegateFunction(FMyNativeDelegate delegate)
{
    ...
}

void MyBlueprintDelegateFunction(FMyBlueprintDelegate delegate)
{
    MyNativeDelegateFunction(Delegates::AsNative(delegate));
}
Template Parameters
DynamicThe origin type, i.e. the dynamic delegate. Will be auto-deduced.
NativeDelegateTypeThe target type, i.e. the delegate that you want to produce. Will be auto-deduced from Dynamic.
Parameters
dynamicDelegateThe dynamic delegate that will be converted

Definition at line 60 of file AsNative.h.

◆ From() [1/12]

template<CSharedRef Object, CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > Mcro::Delegates::From ( const Object & self,
Function && func )

Maps to CreateSPLambda

Definition at line 71 of file DelegateFrom.h.

◆ From() [2/12]

template<CSharedRef Object, CFunctionLike Function, typename... Captures>
requires TFunction_IsMember<Function> && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > Mcro::Delegates::From ( const Object & self,
Function func,
const Captures &... captures )

Maps to CreateSP

Definition at line 116 of file DelegateFrom.h.

◆ From() [3/12]

template<CSharedFromThis Object, CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > Mcro::Delegates::From ( const Object * self,
Function && func )

Maps to CreateSPLambda (SharedFromThis)

Definition at line 85 of file DelegateFrom.h.

◆ From() [4/12]

template<CPlainClass Object, CFunctionLike Function, typename... Captures>
requires TFunction_IsMember<Function> && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > Mcro::Delegates::From ( const Object * self,
Function func,
const Captures &... captures )

Maps to CreateRaw

Maps to CreateSP (SharedFromThis)

Maps to CreateUObject

Definition at line 108 of file DelegateFrom.h.

◆ From() [5/12]

template<CDynamicMulticastDelegate Dynamic>
TNative< typename Dynamic::FDelegate > Mcro::Delegates::From ( Dynamic & multicast)

Broadcast a dynamic multicast delegate when the returned delegate is executed.

Template Parameters
DynamicThe type of the input dynamic multicast delegate
Parameters
multicastinput dynamic multicast delegate
Todo
Captures... and bound object

Definition at line 215 of file DelegateFrom.h.

◆ From() [6/12]

template<CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > Mcro::Delegates::From ( Function && func)

Maps to CreateLambda

Definition at line 64 of file DelegateFrom.h.

◆ From() [7/12]

template<CFunctionLike Function, typename... Captures>
requires (!TFunction_IsMember<Function>) && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > Mcro::Delegates::From ( Function func,
const Captures &... captures )

Maps to CreateStatic

Definition at line 57 of file DelegateFrom.h.

◆ From() [8/12]

template<typename Object , CDynamicMulticastDelegate Dynamic>
TNative< typename Dynamic::FDelegate > Mcro::Delegates::From ( Object && self,
Dynamic & multicast )

Broadcast a dynamic multicast delegate when the returned delegate is executed.

Template Parameters
DynamicThe type of the input dynamic multicast delegate
Parameters
selfany type of binding object other From overloads accept
multicastinput dynamic multicast delegate
Todo
Captures... and bound object

Definition at line 235 of file DelegateFrom.h.

◆ From() [9/12]

template<typename Object , typename... Args>
TDelegate< void(Args...)> Mcro::Delegates::From ( Object && self,
TMulticastDelegate< void(Args...)> & multicast )

Broadcast a multicast delegate when the returned delegate is executed with a binding object.

Parameters
selfany type of binding object other From overloads accept
multicastinput multicast delegate
Todo
Captures... and bound object

Definition at line 178 of file DelegateFrom.h.

◆ From() [10/12]

template<CSharedFromThis Object, CFunctorObject Function>
TDelegate< TFunction_Signature< Function > > Mcro::Delegates::From ( Object * self,
Function && func )

Maps to CreateSPLambda (SharedFromThis)

Maps to CreateWeakLambda

Definition at line 78 of file DelegateFrom.h.

◆ From() [11/12]

template<CPlainClass Object, CFunctionLike Function, typename... Captures>
requires TFunction_IsMember<Function> && (!CFunctorObject<Function>)
TInferredDelegate< Function, Captures... > Mcro::Delegates::From ( Object * self,
Function func,
const Captures &... captures )

Maps to CreateRaw

Maps to CreateSP (SharedFromThis)

Maps to CreateUObject

Definition at line 100 of file DelegateFrom.h.

◆ From() [12/12]

template<typename... Args>
TDelegate< void(Args...)> Mcro::Delegates::From ( TMulticastDelegate< void(Args...)> & multicast)

Broadcast a multicast delegate when the returned delegate is executed.

Parameters
multicastinput multicast delegate
Todo
Captures... and bound object

Definition at line 162 of file DelegateFrom.h.