FSparseDelegateStorage

Sparse delegates can be used for infrequently bound dynamic delegates so that the object uses only 1 byte of storage instead of having the full overhead of the delegate invocation list.

Windows
MacOS
Linux

References

Module

CoreUObject

Header

/Engine/Source/Runtime/CoreUObject/Public/UObject/SparseDelegate.h

Include

#include "UObject/SparseDelegate.h"

Syntax

struct FSparseDelegateStorage

Remarks

Sparse delegates can be used for infrequently bound dynamic delegates so that the object uses only 1 byte of storage instead of having the full overhead of the delegate invocation list. The cost to invoke, add, remove, etc. from the delegate is higher than using the delegate directly and thus the memory savings benefit should be traded off against the frequency with which you would expect the delegate to be bound.Helper class for handling sparse delegate bindings

Functions

Name Description

Public function Static

bool

 

Add

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    FScriptDelegate Delegate
)

Binds a sparse delegate to the owner. Returns if the delegate was successfully bound.

Public function Static

bool

 

AddUnique

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    FScriptDelegate Delegate
)

Binds a sparse delegate to the owner, verifying first that the delegate is not already bound.

Public function Static

void

 

Clear

(
    const UObject* DelegateOwner,
    const FName DelegateName
)

Clear all of the named sparse delegate bindings from the owner.

Public function Static

bool

 

Contains

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    const FScriptDelegate& Delegate
)

Returns whether a sparse delegate is bound to the owner.

Public function Static

bool

 

Contains

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    const UObject* InObject,
    FName InFunctionName
)

Returns whether a sparse delegate is bound to the owner.

Public function Static

FMulticastSc...

 

GetMulticastDelegate

(
    const UObject* DelegateOwner,
    const FName DelegateName
)

Acquires the actual Multicast Delegate from the annotation if any delegates are bound to it.

Public function Static

TSharedPtr< ...

 

GetSharedMulticastDelegate

(
    const UObject* DelegateOwner,
    const FName DelegateName
)

Acquires the actual Multicast Delegate from the annotation if any delegates are bound to it as a shared pointer.

Public function Static

void

 

RegisterDelegateOffset

(
    const UObject* OwningObject,
    FName DelegateName,
    size_t OffsetToOwner
)

Registers the sparse delegate so that the offset can be determined.

Public function Static

bool

 

Remove

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    const FScriptDelegate& Delegate
)

Removes a delegate binding from the owner's sparse delegate storage.

Public function Static

bool

 

Remove

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    const UObject* InObject,
    FName InFunctionName
)

Removes a delegate binding from the owner's sparse delegate storage.

Public function Static

bool

 

RemoveAll

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    const UObject* UserObject
)

Removes all sparse delegate binding from the owner for a given object.

Public function Static

FSparseDeleg...

 

ResolveSparseDelegate

(
    const UObject* OwningObject,
    FName DelegateName
)

Using the registry of sparse delegates recover the FSparseDelegate address from the UObject and name.

Public function Static

UObject *...

 

ResolveSparseOwner

(
    const FSparseDelegate& SparseDeleg...,
    const FName OwningClassName,
    const FName DelegateName
)

Using the registry of sparse delegates recover the UObject owner from the FSparseDelegate address owning class and delegate names.

Public function Static

void

 

SetMulticastDelegate

(
    const UObject* DelegateOwner,
    const FName DelegateName,
    FMulticastScriptDelegate Delegate
)

Directly sets the Multicast Delegate for this object/delegatename pair.

Public function Static

void

 

SparseDelegateReport

(
    const TArray< FString >&,
    UWorld*,
    FOutputDevice&
)

Outputs a report about which delegates are bound.

Typedefs

Name

Description

FSparseDelegateMap

Delegate map is a map of Delegate names to a shared pointer of the multicast script delegate

Constants

Name

Description

SparseDelegateMapCritical

Critical Section for locking access to the sparse delegate map

SparseDelegateObjectListener

A listener to get notified when objects have been deleted and remove them from the map

SparseDelegateObjectOffsets

Sparse delegate offsets are indexed by ActorClass/DelegateName pair

SparseDelegates

Map of objects to the map of delegates that are bound to that object

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss