Navigation
API > API/Runtime > API/Runtime/CoreUObject
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
| Name | FSparseDelegateStorage |
| Type | struct |
| Header File | /Engine/Source/Runtime/CoreUObject/Public/UObject/SparseDelegate.h |
| Include Path | #include "UObject/SparseDelegate.h" |
Syntax
struct FSparseDelegateStorage
Structs
| Name | Remarks |
|---|---|
| FObjectListener |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FSparseDelegateMap | TMap< FName, TSharedPtr< FMulticastScriptDelegate > > | Delegate map is a map of Delegate names to a shared pointer of the multicast script delegate | UObject/SparseDelegate.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| SparseDelegateMapCritical | FTransactionallySafeCriticalSection | Critical Section for locking access to the sparse delegate map | UObject/SparseDelegate.h |
| SparseDelegateObjectListener | FObjectListener | A listener to get notified when objects have been deleted and remove them from the map | UObject/SparseDelegate.h |
| SparseDelegateObjectOffsets | TMap< TPair< FName, FName >, size_t > | Sparse delegate offsets are indexed by ActorClass/DelegateName pair | UObject/SparseDelegate.h |
| SparseDelegates | TMap< const UObjectBase *, FSparseDelegateMap > | Map of objects to the map of delegates that are bound to that object | UObject/SparseDelegate.h |
Functions
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Binds a sparse delegate to the owner. Returns if the delegate was successfully bound. | UObject/SparseDelegate.h | ||
| Binds a sparse delegate to the owner, verifying first that the delegate is not already bound. | UObject/SparseDelegate.h | ||
| Clear all of the named sparse delegate bindings from the owner. | UObject/SparseDelegate.h | ||
| Returns whether a sparse delegate is bound to the owner. | UObject/SparseDelegate.h | ||
| UObject/SparseDelegate.h | |||
static FMulticastScriptDelegate * GetMulticastDelegate
(
const UObject* DelegateOwner, |
Acquires the actual Multicast Delegate from the annotation if any delegates are bound to it. | UObject/SparseDelegate.h | |
static TSharedPtr< FMulticastScriptDelegate > GetSharedMulticastDelegate
(
const UObject* DelegateOwner, |
Acquires the actual Multicast Delegate from the annotation if any delegates are bound to it as a shared pointer. | UObject/SparseDelegate.h | |
| Registers the sparse delegate so that the offset can be determined. | UObject/SparseDelegate.h | ||
| Removes a delegate binding from the owner's sparse delegate storage. | UObject/SparseDelegate.h | ||
| UObject/SparseDelegate.h | |||
| Removes all sparse delegate binding from the owner for a given object. | UObject/SparseDelegate.h | ||
static FSparseDelegate * ResolveSparseDelegate
(
const UObject* OwningObject, |
Using the registry of sparse delegates recover the FSparseDelegate address from the UObject and name. | UObject/SparseDelegate.h | |
static UObject * ResolveSparseOwner
(
const FSparseDelegate& SparseDelegate, |
Using the registry of sparse delegates recover the UObject owner from the FSparseDelegate address owning class and delegate names. | UObject/SparseDelegate.h | |
static void SetMulticastDelegate
(
const UObject* DelegateOwner, |
Directly sets the Multicast Delegate for this object/delegatename pair. | UObject/SparseDelegate.h | |
static void SparseDelegateReport
(
const TArray< FString >&, |
Outputs a report about which delegates are bound. | UObject/SparseDelegate.h |