MCRO
C++23 utilities for Unreal Engine.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
Mcro::Delegates Namespace Reference

Namespaces

namespace  InferDelegate
 The extra layer of namespace InferDelegate is there for guarding common vocabulary (From) but still allowing the developer to use this namespace for a more terse syntax.
 

Data Structures

struct  FEventPolicy
 Settings for the TEventDelegate class, which defines optional behavior when adding a binding to it. More...
 
struct  TDynamicMethodPtr_Struct
 
struct  TDynamicMethodPtr_Struct< Dynamic >
 
struct  TDynamicSignature_Struct
 
struct  TDynamicSignature_Struct< Dynamic >
 
class  TEventDelegate
 "Extension" of a common TMulticastDelegate. It allows to define optional "flags" when adding a binding, in order to: More...
 
class  TEventDelegate< void(Args...), DefaultPolicy >
 "Extension" of a common TMulticastDelegate. It allows to define optional "flags" when adding a binding, in order to: More...
 
struct  TNative_Struct
 
struct  TNative_Struct< Dynamic >
 
struct  TNativeEvent_Struct
 Map the input dynamic multicast delegate to a conceptually compatible native event delegate type. More...
 

Concepts

concept  CDynamicDelegate
 Constraint given type to a dynamic delegate class.
 
concept  CDynamicMulticastDelegate
 Constraint given type to a dynamic multicast delegate class.
 

Typedefs

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using TRetainingEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.CacheViaCopy = true})>
 Shorthand alias for TEventDelegate which copies arguments to its cache regardless of their qualifiers.
 
template<typename Signature , FEventPolicy DefaultPolicy = {}>
using TBelatedEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Belated = true})>
 Shorthand alias for TEventDelegate which broadcasts listeners immediately once they're added.
 
template<typename Signature , FEventPolicy DefaultPolicy = {}>
using TBelatedRetainingEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Belated = true, .CacheViaCopy = true})>
 Shorthand alias for combination of TRetainingEventDelegate and TBelatedEventDelegate.
 
template<typename Signature , FEventPolicy DefaultPolicy = {}>
using TOneTimeEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Once = true})>
 Shorthand alias for TEventDelegate which broadcasts listeners only once and then they're removed.
 
template<typename Signature , FEventPolicy DefaultPolicy = {}>
using TOneTimeRetainingEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Once = true, .CacheViaCopy = true})>
 Shorthand alias for combination of TRetainingEventDelegate and TOneTimeEventDelegate.
 
template<typename Signature , FEventPolicy DefaultPolicy = {}>
using TOneTimeBelatedEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Once = true, .Belated = true})>
 Shorthand alias for combination of TBelatedEventDelegate and TOneTimeEventDelegate.
 
template<typename Signature , FEventPolicy DefaultPolicy = {}>
using TOneTimeRetainingBelatedEventDelegate
 Collect'em all.
 
template<typename Dynamic , FEventPolicy DefaultPolicy = {}>
using TNativeEvent = typename TNativeEvent_Struct<Dynamic, DefaultPolicy>::Type
 Map the input dynamic multicast delegate to a conceptually compatible native event delegate type.
 
template<CFunctionLike Function, typename... Captures>
using TInferredDelegate
 Infer a delegate type from an input function signature and a list of captures.
 
template<typename Dynamic >
using TDynamicMethodPtr = typename TDynamicMethodPtr_Struct<std::decay_t<Dynamic>>::Type
 Get the native function pointer type compatible with given dynamic (multicast) delegate.
 
template<typename Dynamic >
using TDynamicSignature = typename TDynamicSignature_Struct<std::decay_t<Dynamic>>::Type
 Get the native function signature type compatible with given dynamic (multicast) delegate.
 
template<typename Dynamic >
using TNative = typename TNative_Struct<std::decay_t<Dynamic>>::Type
 Map the input dynamic (multicast) delegate to a conceptually compatible native (multicast) delegate type.
 

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 CSameAsDecayed<MethodPtrTypeDynamic, MethodPtrTypeNative>
NativeDelegateType AsNative (Dynamic &&dynamicDelegate)
 Creates a native delegate that is bound to the same UFunction as the specified dynamic delegate.
 

Typedef Documentation

◆ TBelatedEventDelegate

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TBelatedEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Belated = true})>

Shorthand alias for TEventDelegate which broadcasts listeners immediately once they're added.

Definition at line 386 of file EventDelegate.h.

◆ TBelatedRetainingEventDelegate

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TBelatedRetainingEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Belated = true, .CacheViaCopy = true})>

Shorthand alias for combination of TRetainingEventDelegate and TBelatedEventDelegate.

Definition at line 390 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 73 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 92 of file Traits.h.

◆ TInferredDelegate

template<CFunctionLike Function, typename... Captures>
using Mcro::Delegates::TInferredDelegate
Initial value:
TDelegate<
TFunction_Return<Function>,
TTrimEnd<sizeof...(Captures), TFunction_Arguments<Function>>
>,
FDefaultDelegateUserPolicy
>
typename Detail::TFunctionFromTuple_Struct< Return, std::decay_t< Tuple > >::Type TFunctionFromTuple
Compose a function type from a tuple of arguments and a return type.
typename TTrimEnd_Struct< Count, Tuple >::Type TTrimEnd
Disregard the last Count elements of the input tuple.
Definition Tuples.h:193

Infer a delegate type from an input function signature and a list of captures.

The resulting delegate signature will trim the "Captures" from the input function signature. This is used in From overloads to allow binding functions with extra arguments to a delegate which has fewer (as the vanilla Unreal delegates API allows to do so)

Definition at line 33 of file Traits.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 111 of file Traits.h.

◆ TNativeEvent

template<typename Dynamic , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TNativeEvent = typename TNativeEvent_Struct<Dynamic, DefaultPolicy>::Type

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

Definition at line 419 of file EventDelegate.h.

◆ TOneTimeBelatedEventDelegate

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TOneTimeBelatedEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Once = true, .Belated = true})>

Shorthand alias for combination of TBelatedEventDelegate and TOneTimeEventDelegate.

Definition at line 402 of file EventDelegate.h.

◆ TOneTimeEventDelegate

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TOneTimeEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Once = true})>

Shorthand alias for TEventDelegate which broadcasts listeners only once and then they're removed.

Definition at line 394 of file EventDelegate.h.

◆ TOneTimeRetainingBelatedEventDelegate

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TOneTimeRetainingBelatedEventDelegate
Initial value:
TEventDelegate<Signature,
DefaultPolicy.With({.Once = true, .Belated = true, .CacheViaCopy = true})
>

Collect'em all.

Definition at line 406 of file EventDelegate.h.

◆ TOneTimeRetainingEventDelegate

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TOneTimeRetainingEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.Once = true, .CacheViaCopy = true})>

Shorthand alias for combination of TRetainingEventDelegate and TOneTimeEventDelegate.

Definition at line 398 of file EventDelegate.h.

◆ TRetainingEventDelegate

template<typename Signature , FEventPolicy DefaultPolicy = {}>
using Mcro::Delegates::TRetainingEventDelegate = TEventDelegate<Signature, DefaultPolicy.With({.CacheViaCopy = true})>

Shorthand alias for TEventDelegate which copies arguments to its cache regardless of their qualifiers.

Definition at line 382 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 CSameAsDecayed<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, int32, someParam);
void MyNativeDelegateFunction(FMyNativeDelegate delegate)
{
...
}
void MyBlueprintDelegateFunction(FMyBlueprintDelegate delegate)
{
MyNativeDelegateFunction(Delegates::AsNative(delegate));
}
DECLARE_DYNAMIC_DELEGATE_OneParam(FTestDynamicDelegate, int32, Argument)
NativeDelegateType AsNative(Dynamic &&dynamicDelegate)
Creates a native delegate that is bound to the same UFunction as the specified dynamic delegate.
Definition AsNative.h:63
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 63 of file AsNative.h.