UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IDelegateInstance.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Templates/TypeHash.h"
7#include "UObject/NameTypes.h"
9
14{
15public:
20
23 : ID(0)
24 {
25 }
26
29 : ID(GenerateNewID())
30 {
31 }
32
34 bool IsValid() const
35 {
36 return ID != 0;
37 }
38
40 void Reset()
41 {
42 ID = 0;
43 }
44
45 bool operator==(const FDelegateHandle& Rhs) const
46 {
47 return ID == Rhs.ID;
48 }
49
50 bool operator!=(const FDelegateHandle& Rhs) const
51 {
52 return ID != Rhs.ID;
53 }
54
56 {
57 return GetTypeHash(Key.ID);
58 }
59
60private:
61
67 static CORE_API uint64 GenerateNewID();
68
69 uint64 ID;
70};
71
72#if UE_WITH_REMOTE_OBJECT_HANDLE
73/*
74 * Helper class that validates Delegate object type
75 */
77{
78 const void* UserObject;
79 bool bIsUObject = false;
80public:
81 template<typename UserObjectType>
83 {
84 UE_STATIC_ASSERT_COMPLETE_TYPE(UserObjectType, "FDelegateUserObject(UserObject) UserObject must not be an incomplete type");
85 UserObject = (const void*)InUserObject;
86 bIsUObject = std::is_convertible_v<UserObjectType*, UObject*>;
87 }
88 UE_FORCEINLINE_HINT bool IsUObject() const
89 {
90 return bIsUObject;
91 }
92 UE_FORCEINLINE_HINT const void* GetRaw() const
93 {
94 return UserObject;
95 }
96 UE_FORCEINLINE_HINT const UObject* GetUObject() const
97 {
98 return (const UObject*)UserObject;
99 }
100 UE_FORCEINLINE_HINT operator const void* () const
101 {
102 return UserObject;
103 }
104};
106#else
108using FDelegateUserObjectConst = const void*;
109#endif
110
112{
113public:
117 virtual ~IDelegateInstance() = default;
118
119#if USE_DELEGATE_TRYGETBOUNDFUNCTIONNAME
120
129 virtual FName TryGetBoundFunctionName() const = 0;
130
131#endif
132
138 virtual UObject* GetUObject( ) const = 0;
139
145 virtual const void* GetObjectForTimerManager() const = 0;
146
156
167
174 virtual bool IsCompactable( ) const
175 {
176 return !IsSafeToExecute();
177 }
178
184 virtual bool IsSafeToExecute( ) const = 0;
185
189 virtual FDelegateHandle GetHandle() const = 0;
190};
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const void * FDelegateUserObjectConst
Definition IDelegateInstance.h:108
void * FDelegateUserObject
Definition IDelegateInstance.h:107
#define UE_STATIC_ASSERT_COMPLETE_TYPE(TypeToCheck,...)
Definition StaticAssertCompleteType.h:62
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition IDelegateInstance.h:14
EGenerateNewHandleType
Definition IDelegateInstance.h:17
@ GenerateNewHandle
Definition IDelegateInstance.h:18
void Reset()
Definition IDelegateInstance.h:40
bool operator==(const FDelegateHandle &Rhs) const
Definition IDelegateInstance.h:45
FDelegateHandle()
Definition IDelegateInstance.h:22
friend UE_FORCEINLINE_HINT uint32 GetTypeHash(const FDelegateHandle &Key)
Definition IDelegateInstance.h:55
bool IsValid() const
Definition IDelegateInstance.h:34
FDelegateHandle(EGenerateNewHandleType)
Definition IDelegateInstance.h:28
bool operator!=(const FDelegateHandle &Rhs) const
Definition IDelegateInstance.h:50
Definition NameTypes.h:617
Definition IDelegateInstance.h:112
virtual uint64 GetBoundProgramCounterForTimerManager() const =0
virtual const void * GetObjectForTimerManager() const =0
virtual bool HasSameObject(FDelegateUserObjectConst InUserObject) const =0
virtual FDelegateHandle GetHandle() const =0
virtual ~IDelegateInstance()=default
virtual UObject * GetUObject() const =0
virtual bool IsSafeToExecute() const =0
virtual bool IsCompactable() const
Definition IDelegateInstance.h:174
Definition Object.h:95