UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PackageHarvester.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Map.h"
6#include "Containers/Set.h"
7#include "Containers/Queue.h"
8#include "UObject/NameTypes.h"
9#include "UObject/ObjectPtr.h"
10#include "UObject/SavePackage.h"
11
12enum class ESaveableStatus;
13enum class ESaveRealm : uint32;
14enum class EIllegalRefReason : uint8;
15class FSaveContext;
16class UObject;
17namespace UE::SavePackageUtilities { struct FObjectStatus; }
18struct FWeakObjectPtr;
19struct FLazyObjectPtr;
20struct FSoftObjectPath;
21namespace Verse { struct VCell; }
22
28{
29public:
32 {
33 /* Export to process. Only one of these two should be set. */
34 UObject* Export = nullptr;
35 Verse::VCell* CellExport = nullptr;
36 /* The realms from which this export was harvested. */
38
39 operator bool() const
40 {
41 return Export != nullptr || CellExport != nullptr;
42 }
43 };
44
47 {
48 public:
55 bool IsEmpty() const;
56 private:
57 FPackageHarvester& Harvester;
58 FExportingRealmsArray PreviousExportHarvestingRealms;
59 bool bActive;
60 };
61
62public:
64
66
70#if WITH_VERSE_VM || defined(__INTELLISENSE__)
71 void TryHarvestCellExport(Verse::VCell* InCell);
73#endif
75
80
83
84 // FArchiveUObject implementation
85 virtual FString GetArchiveName() const override;
86 virtual void MarkSearchableName(const TObjectPtr<const UObject>& TypeObject, const FName& ValueName) const override;
87 virtual FArchive& operator<<(UObject*& Obj) override;
88 virtual FArchive& operator<<(struct FWeakObjectPtr& Value) override;
90 virtual FArchive& operator<<(FSoftObjectPath& Value) override;
91 virtual FArchive& operator<<(FName& Name) override;
92 virtual FArchive& operator<<(FObjectPtr& Value) override;
93#if WITH_VERSE_VM || defined(__INTELLISENSE__)
94 virtual FArchive& operator<<(Verse::VCell*& Cell) override;
95#endif
96
97 virtual bool ShouldSkipProperty(const FProperty* InProperty) const override;
98
100 static bool IsObjNative(UObject* InObj);
103
104private:
106 struct FExportDependencies
107 {
108 UObject* CurrentExport = nullptr;
109 Verse::VCell* CurrentCellExport = nullptr;
110 TSet<TObjectPtr<UObject>> ObjectReferences;
111 TSet<TObjectPtr<UObject>> NativeObjectReferences;
112 TSet<Verse::VCell*> CellReferences;
113 int32 ProcessImportDepth = 0;
114 bool bIgnoreDependencies = false;
115 };
116
121 class FExportScope
122 {
123 public:
124 FExportScope(FPackageHarvester& InHarvester, const FExportWithContext& InToProcess);
125 ~FExportScope();
126 private:
127 FPackageHarvester& Harvester;
128 FExportingRealmsArray PreviousExportHarvestingRealms;
129 bool bPreviousFilterEditorOnly;
130 bool bPreviousSavingOptionalObject;
131 };
132
134 class FIgnoreDependenciesScope
135 {
136 public:
137 FIgnoreDependenciesScope(FPackageHarvester& InHarvester);
138 ~FIgnoreDependenciesScope();
139 private:
140 FPackageHarvester& Harvester;
141 bool bPreviousValue;
142 };
143
144private:
145
147 template <typename CallbackType>
148 void ForEachExportHarvestingRealm(CallbackType&& Callback);
149 bool HasAnyExportHarvestingRealms();
150
151 void ResolveOverrides();
152
153 void TryHarvestExportInternal(UObject* InObject, UE::SavePackageUtilities::FObjectStatus& ObjectStatus);
154 void HarvestExport(UObject* InObject, UE::SavePackageUtilities::FObjectStatus& ObjectStatus);
159 void SetInstigatorFromProcessingStack(UE::SavePackageUtilities::FObjectStatus& ObjectStatus,
161
162#if WITH_VERSE_VM || defined(__INTELLISENSE__)
163 void HarvestCellExport(Verse::VCell* InCell);
164 void HarvestCellImport(Verse::VCell* InCell);
165#endif
166
167#if WITH_EDITORONLY_DATA
168 void HarvestImportTypeHierarchyNames(const UObject* Import);
169#endif
170
171 void AppendCurrentExportDependencies();
172 FString GetUnsaveableReason(UObject* Required, ESaveRealm RealmInWhichItIsUnsaveable);
173 ESaveableStatus GetSaveableStatusForRealm(UObject* Obj, ESaveRealm RealmInWhichItIsUnsaveable,
175
177 FHarvestScope EnterRealmsArrayScope(FExportingRealmsArray& Array);
179 FHarvestScope EnterConditionalEditorOnlyScope(bool bIsEditorOnly);
181 FHarvestScope EnterConditionalOptionalObjectScope(TObjectPtr<UObject> Object);
183 FHarvestScope EnterNewExportOnlyScope(UObject* Export);
185 FHarvestScope EnterNotExcludedScope(TObjectPtr<UObject> Object,
188 FHarvestScope EnterNotPreviouslyExcludedScope(TObjectPtr<UObject> Object);
190 FHarvestScope EnterIncludedScope(TObjectPtr<UObject> Object);
192 void GetPreviouslyIncludedRealms(TObjectPtr<UObject> Object, FExportingRealmsArray& OutAlreadyIncluded,
194
195 FHarvestScope EnterIncludedScope(Verse::VCell* Cell);
196 void GetPreviouslyIncludedRealms(Verse::VCell* Cell, FExportingRealmsArray& OutAlreadyIncluded,
198
199 FSaveContext& SaveContext;
200 TQueue<FExportWithContext> ExportsToProcess;
201 FExportDependencies CurrentExportDependencies;
202 TMap<UObject*, TSet<FProperty*>> TransientPropertyOverrides;
203 FExportingRealmsArray CurrentExportHarvestingRealms;
204};
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 bool
Definition NetworkReplayStreaming.h:178
ESaveRealm
Definition SaveContext.h:82
EIllegalRefReason
Definition SaveContext.h:92
ESaveableStatus
Definition SaveContext.h:111
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
friend FArchive & operator<<(FArchive &Ar, ANSICHAR &Value)
Definition Archive.h:1387
Definition Archive.h:1208
Definition NameTypes.h:617
Definition PackageHarvester.h:47
FHarvestScope(const FHarvestScope &Other)=delete
~FHarvestScope()
Definition PackageHarvester.cpp:306
FHarvestScope & operator=(const FHarvestScope &Other)=delete
bool IsEmpty() const
Definition PackageHarvester.cpp:314
FHarvestScope & operator=(FHarvestScope &&Other)=delete
Definition PackageHarvester.h:28
void HarvestPackageHeaderName(FName Name)
Definition PackageHarvester.cpp:1294
TArray< ESaveRealm, TInlineAllocator< 2 > > FExportingRealmsArray
Definition PackageHarvester.h:30
virtual void MarkSearchableName(const TObjectPtr< const UObject > &TypeObject, const FName &ValueName) const override
Definition PackageHarvester.cpp:968
void HarvestSearchableName(TObjectPtr< UObject > TypeObject, FName Name)
Definition PackageHarvester.cpp:1302
void TryHarvestExport(UObject *InObject, UE::SavePackageUtilities::FObjectStatus &ObjectStatus)
Definition PackageHarvester.cpp:693
static bool ShouldObjectBeHarvestedInOptionalRealm(TObjectPtr< UObject > InObj, FSaveContext &InSaveContext)
Definition PackageHarvester.cpp:497
void HarvestExportDataName(FName Name)
Definition PackageHarvester.cpp:1286
void HarvestDependency(TObjectPtr< UObject > InObj, bool bIsNative)
Definition PackageHarvester.cpp:1254
virtual FString GetArchiveName() const override
Definition PackageHarvester.cpp:963
virtual bool ShouldSkipProperty(const FProperty *InProperty) const override
Definition PackageHarvester.cpp:1195
void ProcessExport(const FExportWithContext &InProcessContext)
Definition PackageHarvester.cpp:539
bool CurrentExportHasDependency(TObjectPtr< UObject > InObj, ESaveRealm HarvestingRealm) const
Definition PackageHarvester.cpp:1280
static bool IsObjNative(UObject *InObj)
Definition PackageHarvester.cpp:485
TMap< UObject *, TSet< FProperty * > > ReleaseTransientPropertyOverrides()
Definition PackageHarvester.cpp:1249
FHarvestScope EnterRootReferencesScope()
Definition PackageHarvester.cpp:319
FExportWithContext PopExportToProcess()
Definition PackageHarvester.cpp:532
Definition UnrealType.h:174
Definition SaveContext.h:588
Definition UnrealString.h.inl:34
Definition Queue.h:48
Definition Object.h:95
Definition PackageHarvester.cpp:207
Definition Archive.h:36
Definition LazyObjectPtr.h:151
Definition ObjectPtr.h:55
Definition PackageHarvester.h:32
FExportingRealmsArray HarvestedFromRealms
Definition PackageHarvester.h:37
UObject * Export
Definition PackageHarvester.h:34
Verse::VCell * CellExport
Definition PackageHarvester.h:35
Definition SoftObjectPath.h:56
Definition WeakObjectPtr.h:49
Definition ObjectPtr.h:488
Definition SaveContext.h:137