UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DependsNode.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"
11
13
16{
17public:
19 static constexpr uint32 PackageFlagWidth = 3;
20 static constexpr uint32 SearchableNameFlagWidth = 0;
21 static constexpr uint32 ManageFlagWidth = 2;
24 static constexpr uint32 SearchableNameFlagSetWidth = 0;
27
28public:
31
33 void PrintNode() const;
35 void PrintDependencies() const;
37 void PrintReferencers() const;
39 void GetDependencies(TArray<FDependsNode*>& OutDependencies,
43 void GetDependencies(TArray<FAssetIdentifier>& OutDependencies,
46 void GetDependencies(TArray<FAssetDependency>& OutDependencies,
57 FName GetPackageName() const;
59 const FAssetIdentifier& GetIdentifier() const;
60 bool IsScriptPath() const;
78 void RefreshReferencers();
84 void ClearReferencers();
91 void RemoveLinks(const TUniqueFunction<bool(const FDependsNode*)>& ShouldRemove);
95 SIZE_T GetAllocatedSize(void) const;
96
97 typedef TUniqueFunction<void(
118 bool bDuplicate
128 const FDependsNode* DependsNode,
131
133 template <class T>
134 void IterateOverReferencers(const T& InCallback) const;
135
139 void Reserve(const FDependsNode* Other);
140
141 bool GetAllowShrinking() const;
142 void SetAllowShrinking(bool bAllowShrinking);
143
148
161 FSaveScratch& Scratch, const FAssetRegistrySerializationOptions& Options) const;
169 template <bool bLatestVersion>
170 void SerializeLoad(FArchive& Ar,
172 FLoadScratch& Scratch, FAssetRegistryVersion::Type Version);
173
175 FDependsNode* PreallocatedDependsNodeDataBuffer, int32 NumDependsNodes, bool bSerializeDependencies);
176
179 bool IsReferencersSorted() const;
180 void SetIsReferencersSorted(bool bValue);
186 void SetIsScriptDependenciesInitialized(bool bValue);
187
188private:
189
194 void PrintDependenciesRecursive(const FString& Indent, TSet<const FDependsNode*>& VisitedNodes) const;
199 void PrintReferencersRecursive(const FString& Indent, TSet<const FDependsNode*>& VisitedNodes) const;
200
201 void ConstructFlags();
202
203 template <bool bLatestVersion>
204 void SerializeLoad_PackageDependencies(FArchive& Ar,
206 FLoadScratch& Scratch, FAssetRegistryVersion::Type Version);
207 template <bool bLatestVersion>
208 void SerializeLoad_NameDependencies(FArchive& Ar,
210 FLoadScratch& Scratch, FAssetRegistryVersion::Type Version);
211 template <bool bLatestVersion>
212 void SerializeLoad_ManageDependencies(FArchive& Ar,
214 FLoadScratch& Scratch, FAssetRegistryVersion::Type Version);
215 template <bool bLatestVersion>
216 void SerializeLoad_Referencers(FArchive& Ar,
218 FLoadScratch& Scratch, FAssetRegistryVersion::Type Version);
219
221 FAssetIdentifier Identifier;
222 FDependsNodeList PackageDependencies;
223 FDependsNodeList NameDependencies;
224 FDependsNodeList ManageDependencies;
225 FDependsNodeList Referencers;
226 TBitArray<> PackageFlags;
227 TBitArray<> ManageFlags;
228
229 // Transient flags that are not serialized
230 uint32 PackageIsSorted : 1;
231 uint32 SearchableNameIsSorted : 1;
232 uint32 ManageIsSorted : 1;
233 uint32 ReferencersIsSorted : 1;
234 uint32 DependenciesInitialized : 1;
235 uint32 bScriptPath : 1;
237 uint32 bAllowShrinking : 1;
238
240};
241
243{
248
251 {
252 PackageDependenciesSize = Node.PackageDependencies.Num();
253 NameDependenciesSize = Node.NameDependencies.Num();
254 ManageDependenciesSize = Node.ManageDependencies.Num();
255 ReferencersSize = Node.Referencers.Num();
256 }
257
259 {
260 Ar << Reservations.PackageDependenciesSize << Reservations.NameDependenciesSize << Reservations.ManageDependenciesSize << Reservations.ReferencersSize;
261 return Ar;
262 }
263};
264
266// Inline implementations
268
270{
271 ConstructFlags();
272}
273
275{
276 ConstructFlags();
278}
279
281{
282 return Identifier.PackageName;
283}
284
286{
287 return Identifier;
288}
289
290inline bool FDependsNode::IsScriptPath() const
291{
292 return bScriptPath != 0;
293}
294
296{
297 return PackageDependencies.GetAllocatedSize() + PackageFlags.GetAllocatedSize()
298 + NameDependencies.GetAllocatedSize() + ManageDependencies.GetAllocatedSize() + ManageFlags.GetAllocatedSize()
299 + Referencers.GetAllocatedSize();
300}
301
302template <class T>
304{
305 for (FDependsNode* Referencer : Referencers)
306 {
307 InCallback(Referencer);
308 }
309}
310
321
323{
324 Reserve(InReservations.PackageDependenciesSize, InReservations.NameDependenciesSize,
325 InReservations.ManageDependenciesSize, InReservations.ReferencersSize);
326}
327
329{
330 Reserve(Other->PackageDependencies.Num(), Other->NameDependencies.Num(),
331 Other->ManageDependencies.Num(), Other->Referencers.Num());
332}
333
335{
336 return bAllowShrinking;
337}
338
340{
341 bAllowShrinking = InAllowShrinking;
342}
343
345{
346 return (0x01 * (static_cast<uint8>(Properties & UE::AssetRegistry::EDependencyProperty::Hard) != 0))
347 | (0x02 * (static_cast<uint8>(Properties & UE::AssetRegistry::EDependencyProperty::Game) != 0))
348 | (0x04 * (static_cast<uint8>(Properties & UE::AssetRegistry::EDependencyProperty::Build) != 0));
349}
350
352{
353 return static_cast<UE::AssetRegistry::EDependencyProperty>(
354 (static_cast<uint32>(UE::AssetRegistry::EDependencyProperty::Hard) * ((Bits & 0x01) != 0))
355 | (static_cast<uint32>(UE::AssetRegistry::EDependencyProperty::Game) * ((Bits & 0x02) != 0))
356 | (static_cast<uint32>(UE::AssetRegistry::EDependencyProperty::Build) * ((Bits & 0x04) != 0))
357 );
358}
360{
361 return (0x01 * (static_cast<uint8>(Properties & UE::AssetRegistry::EDependencyProperty::Direct) != 0))
362 | (0x02 * (static_cast<uint8>(Properties & UE::AssetRegistry::EDependencyProperty::CookRule) != 0));
363}
364
372
373inline void FDependsNode::ConstructFlags()
374{
375 PackageIsSorted = 1;
376 SearchableNameIsSorted = 1;
377 ManageIsSorted = 1;
378 ReferencersIsSorted = 1;
379 DependenciesInitialized = 0;
380 bScriptPath = 0;
381}
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
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
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition DependsNode.h:16
bool IsScriptDependenciesInitialized() const
Definition DependsNode.cpp:1440
void RemoveReferencers(const TSet< FDependsNode * > &InReferencers)
Definition DependsNode.cpp:511
void GetPackageReferencers(TArray< TPair< FAssetIdentifier, FPackageFlagSet > > &OutReferencers)
Definition DependsNode.cpp:341
bool ContainsDependency(const FDependsNode *InDependency, UE::AssetRegistry::EDependencyCategory Category=UE::AssetRegistry::EDependencyCategory::All, const UE::AssetRegistry::FDependencyQuery &Flags=UE::AssetRegistry::FDependencyQuery()) const
Definition DependsNode.cpp:706
static UE::AssetRegistry::EDependencyProperty ByteToPackageProperties(uint8 Bits)
Definition DependsNode.h:351
void ClearDependencies(UE::AssetRegistry::EDependencyCategory Category=UE::AssetRegistry::EDependencyCategory::All)
Definition DependsNode.cpp:550
TUniqueFunction< void(FDependsNode *Dependency, UE::AssetRegistry::EDependencyCategory Category, UE::AssetRegistry::EDependencyProperty Properties, bool bDuplicate)> FIterateDependenciesCallback
Definition DependsNode.h:119
bool IsReferencersSorted() const
Definition DependsNode.cpp:1425
TPropertyCombinationSet< ManageFlagWidth > FManageFlagSet
Definition DependsNode.h:25
void IterateOverReferencers(const T &InCallback) const
Definition DependsNode.h:303
void SetAllowShrinking(bool bAllowShrinking)
Definition DependsNode.h:339
void GetDependencies(TArray< FDependsNode * > &OutDependencies, UE::AssetRegistry::EDependencyCategory Category=UE::AssetRegistry::EDependencyCategory::All, const UE::AssetRegistry::FDependencyQuery &Flags=UE::AssetRegistry::FDependencyQuery()) const
Definition DependsNode.cpp:248
void ClearReferencers()
Definition DependsNode.cpp:585
void SetIsDependencyListSorted(UE::AssetRegistry::EDependencyCategory Category, bool bValue)
Definition DependsNode.cpp:1395
void IterateOverDependencies(const FIterateDependenciesCallback &InCallback, UE::AssetRegistry::EDependencyCategory Category=UE::AssetRegistry::EDependencyCategory::All, const UE::AssetRegistry::FDependencyQuery &Flags=UE::AssetRegistry::FDependencyQuery()) const
Definition DependsNode.cpp:214
void AddDependency(FDependsNode *InDependency, UE::AssetRegistry::EDependencyCategory InDependencyType, UE::AssetRegistry::EDependencyProperty InProperties)
Definition DependsNode.cpp:392
void RemoveReferencer(FDependsNode *InReferencer)
Definition DependsNode.cpp:506
void SerializeSave(FArchive &Ar, const TUniqueFunction< int32(FDependsNode *, bool)> &GetSerializeIndexFromNode, FSaveScratch &Scratch, const FAssetRegistrySerializationOptions &Options) const
Definition DependsNode.cpp:822
void SetIsScriptDependenciesInitialized(bool bValue)
Definition DependsNode.cpp:1445
TArray< FDependsNode * > FDependsNodeList
Definition DependsNode.h:18
static constexpr uint32 ManageFlagWidth
Definition DependsNode.h:21
void RefreshReferencers()
Definition DependsNode.cpp:532
bool IsDependencyListSorted(UE::AssetRegistry::EDependencyCategory Category) const
Definition DependsNode.cpp:1373
const FAssetIdentifier & GetIdentifier() const
Definition DependsNode.h:285
void SetIdentifier(const FAssetIdentifier &InIdentifier)
Definition DependsNode.cpp:32
static uint8 PackagePropertiesToByte(UE::AssetRegistry::EDependencyProperty Properties)
Definition DependsNode.h:344
void LegacySerializeLoad_BeforeFlags(FArchive &Ar, FAssetRegistryVersion::Type Version, FDependsNode *PreallocatedDependsNodeDataBuffer, int32 NumDependsNodes, bool bSerializeDependencies)
Definition DependsNode.cpp:1154
void RemoveManageReferencesToNode()
Definition DependsNode.cpp:590
static uint8 ManagePropertiesToByte(UE::AssetRegistry::EDependencyProperty Properties)
Definition DependsNode.h:359
static constexpr uint32 SearchableNameFlagWidth
Definition DependsNode.h:20
void PrintNode() const
Definition DependsNode.cpp:9
void PrintDependencies() const
Definition DependsNode.cpp:18
bool IsScriptPath() const
Definition DependsNode.h:290
FDependsNode()
Definition DependsNode.h:269
void GetReferencers(TArray< FDependsNode * > &OutReferencers, UE::AssetRegistry::EDependencyCategory Category=UE::AssetRegistry::EDependencyCategory::All, const UE::AssetRegistry::FDependencyQuery &Flags=UE::AssetRegistry::FDependencyQuery()) const
Definition DependsNode.cpp:294
int32 GetConnectionCount() const
Definition DependsNode.cpp:817
TPropertyCombinationSet< PackageFlagWidth > FPackageFlagSet
Definition DependsNode.h:22
void RemoveDependency(FDependsNode *InDependency, UE::AssetRegistry::EDependencyCategory Category=UE::AssetRegistry::EDependencyCategory::All)
Definition DependsNode.cpp:488
SIZE_T GetAllocatedSize(void) const
Definition DependsNode.h:295
static constexpr uint32 PackageFlagWidth
Definition DependsNode.h:19
void AddReferencer(FDependsNode *InReferencer)
Definition DependsNode.cpp:435
void SetIsReferencersSorted(bool bValue)
Definition DependsNode.cpp:1430
static constexpr uint32 ManageFlagSetWidth
Definition DependsNode.h:26
static constexpr uint32 SearchableNameFlagSetWidth
Definition DependsNode.h:24
static UE::AssetRegistry::EDependencyProperty ByteToManageProperties(uint8 Bits)
Definition DependsNode.h:365
void Reserve(int32 InNumPackageDependencies, int32 InNumNameDependencies, int32 InNumManageDependencies, int32 InNumReferencers)
Definition DependsNode.h:311
void PrintReferencers() const
Definition DependsNode.cpp:25
static constexpr uint32 PackageFlagSetWidth
Definition DependsNode.h:23
FName GetPackageName() const
Definition DependsNode.h:280
bool GetAllowShrinking() const
Definition DependsNode.h:334
void AddPackageDependencySet(FDependsNode *InDependency, const FPackageFlagSet &PropertyCombinationSet)
Definition DependsNode.cpp:424
void RemoveLinks(const TUniqueFunction< bool(const FDependsNode *)> &ShouldRemove)
Definition DependsNode.cpp:696
void SerializeLoad(FArchive &Ar, const TUniqueFunction< FDependsNode *(int32)> &GetNodeFromSerializeIndex, FLoadScratch &Scratch, FAssetRegistryVersion::Type Version)
Definition DependsNode.cpp:1129
Definition NameTypes.h:617
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize(void) const
Definition Array.h:1059
UE_FORCEINLINE_HINT void Reserve(SizeType Number)
Definition Array.h:3016
uint32 GetAllocatedSize(void) const
Definition BitArray.h:1062
void Reserve(int32 Number)
Definition BitArray.h:800
Definition PropertyCombinationSet.h:33
static constexpr uint32 StorageBitCount
Definition PropertyCombinationSet.h:35
Definition FunctionFwd.h:19
EDependencyProperty
Definition AssetRegistryInterface.h:88
EDependencyCategory
Definition AssetRegistryInterface.h:71
Definition AssetIdentifier.h:12
FName PackageName
Definition AssetIdentifier.h:14
Definition AssetRegistryState.h:58
Type
Definition AssetData.h:73
Definition DependsNode.h:243
int32 ManageDependenciesSize
Definition DependsNode.h:246
FDependsNodeReservations(const FDependsNode &Node)
Definition DependsNode.h:250
int32 ReferencersSize
Definition DependsNode.h:247
friend FArchive & operator<<(FArchive &Ar, FDependsNodeReservations &Reservations)
Definition DependsNode.h:258
int32 PackageDependenciesSize
Definition DependsNode.h:244
FDependsNodeReservations()=default
int32 NameDependenciesSize
Definition DependsNode.h:245
Definition DependsNode.h:163
TArray< FDependsNode * > PointerDependencies
Definition DependsNode.h:166
TArray< int32 > InDependencies
Definition DependsNode.h:164
TArray< uint32 > InFlagBits
Definition DependsNode.h:165
TArray< int32 > SortIndexes
Definition DependsNode.h:167
Definition DependsNode.h:152
int32 SerializeIndex
Definition DependsNode.h:153
int32 ListIndex
Definition DependsNode.h:154
Definition DependsNode.h:150
TArray< int32 > OutDependencies
Definition DependsNode.h:157
TBitArray OutFlagBits
Definition DependsNode.h:158
TArray< FSortInfo > SortInfos
Definition DependsNode.h:156
Definition Tuple.h:652
Definition AssetRegistryInterface.h:255