UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FieldNotificationDelegate.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Algo/BinarySearch.h"
6#include "Containers/Array.h"
8#include "CoreMinimal.h"
10#include "FieldNotificationId.h"
12#include "Templates/IdentityFunctor.h"
13#include "Templates/Less.h"
15#include "UObject/NameTypes.h"
17
18#include <limits>
19
20class UObject;
21
23{
24
26{
27public:
30
31private:
32 struct FInvocationKey
33 {
35 FFieldId Id;
36 FName DynamicName;
37 bool operator<(const FInvocationKey& Element) const
38 {
39 return Id.GetName().FastLess(Element.Id.GetName());
40 }
41 };
42
43 struct FInvocationElement
44 {
45 FInvocationKey Key;
46 FDelegate Delegate;
47 bool operator<(const FInvocationElement& InElement) const
48 {
49 return Key < InElement.Key;
50 }
51 };
52
53 friend bool operator<(const FInvocationElement& A, const FInvocationKey& B)
54 {
55 return A.Key < B;
56 }
57 friend bool operator<(const FInvocationKey& A, const FInvocationElement& B)
58 {
59 return A < B.Key;
60 }
61 friend bool operator<(const FInvocationElement& A, const FFieldId& B)
62 {
63 return A.Key.Id.GetName().FastLess(B.GetName());
64 }
65 friend bool operator<(const FFieldId& A, const FInvocationElement& B)
66 {
67 return A.GetName().FastLess(B.Key.Id.GetName());
68 }
69
70 using InvocationListType = TArray<FInvocationElement>;
71
72public:
75
77 {
78 bool bRemoved = false;
80 const UObject* Object = nullptr;
82 };
85
87 {
88 bool bRemoved = false;
90 };
93
101
103
105
117
118private:
119 int32 LowerBound(FFieldId InFieldId) const
120 {
121 int32 Num = AddedEmplaceAt > GetNum(Delegates) ? GetNum(Delegates) : AddedEmplaceAt;
123 }
124
125 int32 LowerBound(const FInvocationKey& InKey) const
126 {
127 int32 Num = AddedEmplaceAt > GetNum(Delegates) ? GetNum(Delegates) : AddedEmplaceAt;
129 }
130
131 int32 UpperBound(FFieldId InFieldId) const
132 {
133 int32 Num = AddedEmplaceAt > GetNum(Delegates) ? GetNum(Delegates) : AddedEmplaceAt;
135 }
136
137 int32 UpperBound(const FInvocationKey& InKey) const
138 {
139 int32 Num = AddedEmplaceAt > GetNum(Delegates) ? GetNum(Delegates) : AddedEmplaceAt;
141 }
142
143 void ExecuteLockOperations();
144 void RemoveElement(FInvocationElement& Element, int32 Index, FRemoveResult& Result);
145 void CompleteRemove(FRemoveResult& Result) const;
146 template<typename TRemoveOrUnbind>
147 void RemoveFrom(TRemoveOrUnbind& RemoveOrUnbind, FFieldId FieldId, bool& bFieldPresent);
148
149private:
150 InvocationListType Delegates;
151 int16 DelegateLockCount = 0;
152 int16 CompactionCount = 0;
153 uint16 AddedEmplaceAt = std::numeric_limits<uint16>::max();
154};
155
156} //namespace
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const void * FDelegateUserObjectConst
Definition IDelegateInstance.h:108
@ Num
Definition MetalRHIPrivate.h:234
auto GetNum(const TStringConversion< Converter, DefaultConversionSize > &Conversion) -> decltype(Conversion.Length())
Definition StringConv.h:808
auto GetData(const TStringConversion< Converter, DefaultConversionSize > &Conversion) -> decltype(Conversion.Get())
Definition StringConv.h:802
uint16_t uint16
Definition binka_ue_file_header.h:7
Definition IDelegateInstance.h:14
Definition NameTypes.h:617
TDelegate< void(UObject *, UE::FieldNotification::FFieldId), FNotThreadSafeNotCheckedDelegateUserPolicy > FFieldValueChangedDelegate
Definition INotifyFieldValueChanged.h:29
Definition Array.h:670
Definition DelegateSignatureImpl.inl:310
Definition FieldNotificationDelegate.h:26
friend bool operator<(const FFieldId &A, const FInvocationElement &B)
Definition FieldNotificationDelegate.h:65
FIELDNOTIFICATION_API void Reset()
Definition FieldNotificationDelegate.cpp:446
FIELDNOTIFICATION_API TArray< FDelegateView > GetView() const
Definition FieldNotificationDelegate.cpp:515
friend bool operator<(const FInvocationElement &A, const FFieldId &B)
Definition FieldNotificationDelegate.h:61
friend bool operator<(const FInvocationKey &A, const FInvocationElement &B)
Definition FieldNotificationDelegate.h:57
friend bool operator<(const FInvocationElement &A, const FInvocationKey &B)
Definition FieldNotificationDelegate.h:53
INotifyFieldValueChanged::FFieldValueChangedDelegate FDelegate
Definition FieldNotificationDelegate.h:28
FIELDNOTIFICATION_API FRemoveAllResult RemoveAll(const UObject *InObject, FDelegateUserObjectConst InUserObject)
Definition FieldNotificationDelegate.cpp:293
FIELDNOTIFICATION_API FRemoveFromResult RemoveFrom(const UObject *InObject, FFieldId InFieldId, FDelegateHandle InDelegate)
Definition FieldNotificationDelegate.cpp:208
FIELDNOTIFICATION_API void Broadcast(UObject *InObject, FFieldId InFieldId)
Definition FieldNotificationDelegate.cpp:409
FFieldValueChangedDynamicDelegate FDynamicDelegate
Definition FieldNotificationDelegate.h:29
Definition Object.h:95
SizeType UpperBoundInternal(RangeValueType *First, const SizeType Num, const PredicateValueType &Value, ProjectionType Projection, SortPredicateType SortPredicate)
Definition BinarySearch.h:56
SizeType LowerBoundInternal(RangeValueType *First, const SizeType Num, const PredicateValueType &Value, ProjectionType Projection, SortPredicateType SortPredicate)
Definition BinarySearch.h:23
Definition FieldNotificationLibrary.cpp:16
U16 Index
Definition radfft.cpp:71
Definition IdentityFunctor.h:11
Definition Less.h:19
Definition WeakObjectPtrTemplates.h:25
Definition FieldNotificationId.h:16
Definition FieldNotificationDelegate.h:107
const UObject * KeyObject
Definition FieldNotificationDelegate.h:111
const UObject * BindingObject
Definition FieldNotificationDelegate.h:113
FFieldId KeyField
Definition FieldNotificationDelegate.h:112
FDelegateView(const UObject *InKeyObj, FFieldId InKeyId, const UObject *InObj, FName InFunction)
Definition FieldNotificationDelegate.h:108
FName BindingFunctionName
Definition FieldNotificationDelegate.h:114
int32 RemoveCount
Definition FieldNotificationDelegate.h:96
TBitArray HasFields
Definition FieldNotificationDelegate.h:97
bool bHasOtherBoundDelegates
Definition FieldNotificationDelegate.h:89
bool bRemoved
Definition FieldNotificationDelegate.h:88
Definition FieldNotificationDelegate.h:77
FFieldId FieldId
Definition FieldNotificationDelegate.h:81
bool bHasOtherBoundDelegates
Definition FieldNotificationDelegate.h:79
bool bRemoved
Definition FieldNotificationDelegate.h:78
const UObject * Object
Definition FieldNotificationDelegate.h:80