UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PropertyStateTracking.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
7#if WITH_EDITORONLY_DATA
8
12#include "UObject/Class.h"
13#include "UObject/UnrealType.h"
14
15class FBlake3;
16class FName;
18class UEnum;
19class UObject;
20class UStruct;
21namespace UE { class FPropertyPathNameTree; }
22namespace UE { class FPropertyTypeName; }
23
24#define UE_API COREUOBJECT_API
25
26namespace UE
27{
28
35template <EPropertyValueFlags Flag>
37{
38public:
40 inline explicit TPropertyValueState(const UStruct* InStruct, void* InData)
42 , Data(InData)
43 {
44 }
45
47 inline explicit TPropertyValueState(UObject* Object)
49 , Data(Object)
50 {
51 }
52
54 inline bool ActivateTracking()
55 {
56 return Struct->ActivateTrackingPropertyValueFlag(Flag, Data);
57 }
58
60 inline bool IsTracking() const
61 {
62 return Struct->IsTrackingPropertyValueFlag(Flag, Data);
63 }
64
66 bool IsSet(const FProperty* Property, int32 ArrayIndex = 0) const
67 {
68 bool bIsSet = Struct->HasPropertyValueFlag(Flag, Data, Property, ArrayIndex);
69
70 // This is a temporary workaround to handle the case of an object reference being
71 // garbage collected and set to NULL (see FGarbageEliminationScopeGuard). This if
72 // should be removed once the Editor handles the clearing of deleted object references.
73 if (bIsSet && (Flag == EPropertyValueFlags::Initialized) && Property->HasAnyPropertyFlags(CPF_NonNullable))
74 {
76 {
77 const UObject* PropertyValue = ObjectProperty->LoadObjectPropertyValue_InContainer(Data);
78 if (!PropertyValue)
79 {
80 bIsSet = false;
81 }
82 }
83 }
84
85 return bIsSet;
86 }
87
89 inline void SetTo(bool bValue, const FProperty* Property, int32 ArrayIndex = 0)
90 {
91 Struct->SetPropertyValueFlag(Flag, bValue, Data, Property, ArrayIndex);
92 }
93
95 inline void Set(const FProperty* Property, int32 ArrayIndex = 0)
96 {
97 SetTo(/*bValue*/ true, Property, ArrayIndex);
98 }
99
101 inline void Clear(const FProperty* Property, int32 ArrayIndex = 0)
102 {
103 SetTo(/*bValue*/ false, Property, ArrayIndex);
104 }
105
107 inline void Reset()
108 {
109 Struct->ResetPropertyValueFlags(Flag, Data);
110 }
111
113 inline void Serialize(FStructuredArchiveRecord Record)
114 {
115 Struct->SerializePropertyValueFlags(Flag, Data, Record, GetArchiveFieldName());
116 }
117
118private:
120 {
121 static_assert(Flag == EPropertyValueFlags::Initialized || Flag == EPropertyValueFlags::Serialized);
122 if constexpr (Flag == EPropertyValueFlags::Initialized)
123 {
124 return TEXT("PropertyValueInitializedFlags");
125 }
126 else
127 {
128 return TEXT("PropertyValueSerializedFlags");
129 }
130 }
131
132 const UStruct* Struct = nullptr;
133 void* Data = nullptr;
134};
135
136// A property is initialized if it has a value set on it.
137// A property may be uninitialized if it has no default and has never been set.
138// A property may be uninitialized if it is an unknown property in an InstanceDataObject (IDO)
139// and has no value on a particular instance or has had its value unset while being fixed up.
141
142// A property is serialized if a value was loaded into it during serialization.
143// A property may be initialized without having been serialized because a template object provided a default.
144// A property may be serialized without being initialized if its value was removed following serialization.
146
151{
152public:
154 explicit FUnknownPropertyTree(const UObject* Owner);
155
158
161
163 void Destroy();
164
165private:
166 const UObject* Owner = nullptr;
167};
168
173{
174public:
176 explicit FUnknownEnumNames(const UObject* Owner);
177
186 void Add(const UEnum* Enum, FPropertyTypeName EnumTypeName, FName EnumValueName);
187
195 void Find(FPropertyTypeName EnumTypeName, TArray<FName>& OutNames, bool& bOutHasFlags) const;
196
198 bool IsEmpty() const;
199
201 void Destroy();
202
203private:
204 friend void AppendHash(FBlake3& Builder, const FUnknownEnumNames& EnumNames);
205
206 const UObject* Owner = nullptr;
207};
208
209} // UE
210
211#undef UE_API
212
213#endif // WITH_EDITORONLY_DATA
#define TEXT(x)
Definition Platform.h:1272
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
@ CPF_NonNullable
Object property can never be null.
Definition ObjectMacros.h:431
void AppendHash(FBlake3 &Builder, FName In)
Definition UnrealNames.cpp:3801
Definition Blake3.h:94
Definition NameTypes.h:617
Definition UnrealType.h:2725
Definition UnrealType.h:174
Definition StructuredArchiveSlots.h:144
Definition Array.h:670
Definition SharedPointer.h:692
Definition Class.h:2791
Definition Object.h:95
Definition Class.h:480
GeometryCollection::Facades::FMuscleActivationData Data
Definition MuscleActivationConstraints.h:15
UClass * GetClass(UObject *Obj)
Definition ObjectFwd.cpp:8
Definition AdvancedWidgetsModule.cpp:13
VERSECOMPILER_API bool IsSet()
Definition CommandLine.cpp:63
Definition StructuredArchiveNameHelpers.h:10