UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ObjectSaveContext.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "Containers/Map.h"
8#include "HAL/Platform.h"
11#include "UObject/CookEnums.h"
12#include "UObject/NameTypes.h"
14#if WITH_EDITOR
17#endif
18
19class FPackagePath;
20class IPackageWriter;
21class ITargetPlatform;
22class UPackage;
23struct FSoftObjectPath;
24namespace UE::Cook { class ICookInfo; }
25#if WITH_EDITOR
26namespace UE::Cook { class IDeterminismHelper; }
27#endif
28
67
70{
75
79
83
88 {
90 {
92 }
93 else
94 {
95 SaveOverrides.Add(Target, MoveTemp(InOverride));
96 }
97 }
98
99 // Global Parameters that are read-only by the interfaces
100
107
110
112 UE::Cook::ICookInfo* CookInfo = nullptr;
113
116
118 UObject* Object = nullptr;
119
122
125
128
131
137 bool bProceduralSave = false;
138
144
151
153 bool bSaveSucceeded = true;
154
159 bool bDeterminismDebug = false;
160
161 // Collection variables that are written but not read during the PreSave/PostSave functions
162#if WITH_EDITOR
163 UE_DEPRECATED(5.6, "Use BuildResultDependencies instead.")
169#endif
170
171 // Per-object Output variables; writable from PreSave functions, readable from PostSave functions
172
175
177 bool bCleanupRequired = false;
178
179 // Variables set/read per call to PreSave/PostSave functions
182
184 bool bBaseClassCalled = false;
185
188
189};
190
193{
194public:
196 : Data(InData)
197 {
198 // Note: Doesn't increment NumRefPasses as CollectSaveOverrides is called from PreSave
199 }
200
202 : Data(Other.Data)
203 {
204 // Note: Doesn't increment NumRefPasses as CollectSaveOverrides is called from PreSave
205 }
206
208 bool IsCooking() const { return Data.TargetPlatform != nullptr; }
209
212
218
224 bool IsProceduralSave() const { return Data.bProceduralSave; }
225
227 uint32 GetSaveFlags() const { return Data.SaveFlags; }
228
236
237protected:
239 friend class UObject;
240};
241
244{
245public:
247 : Data(InData)
248 {
249 ++Data.NumRefPasses; // Record the number of copies; used to check whether PreSave is overridden
250 }
251
253 : Data(Other.Data)
254 {
255 ++Data.NumRefPasses; // Record the number of copies; used to check whether PreSave is overridden
256 }
257
263 const TCHAR* GetTargetFilename() const { return *Data.TargetFilename; }
264
266 bool IsCooking() const { return Data.TargetPlatform != nullptr; }
267
270
276
279
280#if WITH_EDITOR
281 UE_DEPRECATED(5.6, "These dependencies should instead be reported in OnCookEvent(UE::Cook::ECookEvent::PlatformCookDependencies, ...) by calling FCookEventContext.AddLoadBuildDependency (@see CookEvents.h).")
285 UE_DEPRECATED(5.6, "These dependencies should instead be reported in OnCookEvent(UE::Cook::ECookEvent::PlatformCookDependencies, ...) by calling FCookEventContext.HarvestCookRuntimeDependencies (@see CookEvents.h).")
286 COREUOBJECT_API void HarvestCookRuntimeDependencies(UObject* HarvestReferencesFrom);
287
292 COREUOBJECT_API bool IsDeterminismDebug() const;
297 COREUOBJECT_API void RegisterDeterminismHelper(const TRefCountPtr<UE::Cook::IDeterminismHelper>& DeterminismHelper);
298#endif
299
305 bool IsProceduralSave() const { return Data.bProceduralSave; }
306
310 bool IsFromAutoSave() const { return (Data.SaveFlags & SAVE_FromAutosave) != 0; }
311
317
319 uint32 GetSaveFlags() const { return Data.SaveFlags; }
320
326
330 UE_DEPRECATED(5.5, "Calling AddSaveOverride in UObject::PreSave is deprecated. Override UObject::CollectSaveOverrides and call AddSaveOverride on its context instead.")
335
336protected:
338 friend class UObject;
339};
340
343{
344public:
349
354
360 const TCHAR* GetTargetFilename() const { return *Data.TargetFilename; }
361
363 bool IsCooking() const { return Data.TargetPlatform != nullptr; }
364
367
373
376
377#if WITH_EDITOR
384
385 UE_DEPRECATED(5.6, "Use AddCookLoadDependency.")
387
397
410 COREUOBJECT_API void HarvestCookRuntimeDependencies(UObject* HarvestReferencesFrom);
411
416 COREUOBJECT_API bool IsDeterminismDebug() const;
421 COREUOBJECT_API void RegisterDeterminismHelper(const TRefCountPtr<UE::Cook::IDeterminismHelper>& DeterminismHelper);
424#endif
425
431 bool IsProceduralSave() const { return Data.bProceduralSave; }
432
436 bool IsFromAutoSave() const { return (Data.SaveFlags & SAVE_FromAutosave) != 0; }
437
443
445 uint32 GetSaveFlags() const { return Data.SaveFlags; }
446
452
453protected:
455};
456
459{
460public:
462 : Data(InData)
463 {
464 ++Data.NumRefPasses; // Record the number of copies; used to check whether PreSave is overridden
465 }
466
468 : Data(Other.Data)
469 {
470 ++Data.NumRefPasses; // Record the number of copies; used to check whether PreSave is overridden
471 }
472
478 const TCHAR* GetTargetFilename() const { return *Data.TargetFilename; }
479
481 bool IsCooking() const { return Data.TargetPlatform != nullptr; }
482
485
491
497 bool IsProceduralSave() const { return Data.bProceduralSave; }
498
502 bool IsFromAutoSave() const { return (Data.SaveFlags & SAVE_FromAutosave) != 0; }
503
509
511 uint32 GetSaveFlags() const { return Data.SaveFlags; }
512
515
517 bool SaveSucceeded() const { return Data.bSaveSucceeded; }
518
524
527
528protected:
530 friend class UObject;
531};
532
551
569
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
OODEFFUNC typedef void OO_U64 * dependencies
Definition oodle2.h:588
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
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
@ SAVE_FromAutosave
Used to indicate this save was initiated automatically.
Definition ObjectMacros.h:100
EObjectSaveContextPhase
Definition ObjectSaveContext.h:31
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ObjectSaveContext.h:193
const ITargetPlatform * GetTargetPlatform() const
Definition ObjectSaveContext.h:211
bool IsCooking() const
Definition ObjectSaveContext.h:208
bool IsCookByTheBook() const
Definition ObjectSaveContext.h:213
FObjectCollectSaveOverridesContext(FObjectSaveContextData &InData)
Definition ObjectSaveContext.h:195
FObjectCollectSaveOverridesContext(const FObjectCollectSaveOverridesContext &Other)
Definition ObjectSaveContext.h:201
bool IsCookOnTheFly() const
Definition ObjectSaveContext.h:214
UE::Cook::ECookingDLC GetCookingDLC() const
Definition ObjectSaveContext.h:217
uint32 GetSaveFlags() const
Definition ObjectSaveContext.h:227
void AddSaveOverride(UObject *Target, FObjectSaveOverride InOverride)
Definition ObjectSaveContext.h:232
bool IsProceduralSave() const
Definition ObjectSaveContext.h:224
bool IsCookTypeUnknown() const
Definition ObjectSaveContext.h:215
UE::Cook::ECookType GetCookType() const
Definition ObjectSaveContext.h:216
FObjectSaveContextData & Data
Definition ObjectSaveContext.h:238
Definition ObjectSaveContext.h:459
bool IsFromAutoSave() const
Definition ObjectSaveContext.h:502
const ITargetPlatform * GetTargetPlatform() const
Definition ObjectSaveContext.h:484
EObjectSaveContextPhase GetPhase() const
Definition ObjectSaveContext.h:526
bool IsUpdatingLoadedPath() const
Definition ObjectSaveContext.h:508
FObjectPostSaveContext(const FObjectPostSaveContext &Other)
Definition ObjectSaveContext.h:467
bool SaveSucceeded() const
Definition ObjectSaveContext.h:517
const TCHAR * GetTargetFilename() const
Definition ObjectSaveContext.h:478
bool IsCooking() const
Definition ObjectSaveContext.h:481
bool IsCookOnTheFly() const
Definition ObjectSaveContext.h:487
UE::Cook::ECookingDLC GetCookingDLC() const
Definition ObjectSaveContext.h:490
bool IsProceduralSave() const
Definition ObjectSaveContext.h:497
bool IsCookByTheBook() const
Definition ObjectSaveContext.h:486
FObjectPostSaveContext(FObjectSaveContextData &InData)
Definition ObjectSaveContext.h:461
FObjectSaveContextData & Data
Definition ObjectSaveContext.h:529
uint32 GetSaveFlags() const
Definition ObjectSaveContext.h:511
UE::Cook::ECookType GetCookType() const
Definition ObjectSaveContext.h:489
bool IsCookTypeUnknown() const
Definition ObjectSaveContext.h:488
uint32 GetOriginalPackageFlags() const
Definition ObjectSaveContext.h:514
bool IsLastConcurrentSave() const
Definition ObjectSaveContext.h:523
Definition ObjectSaveContext.h:554
FObjectPostSaveRootContext(const FObjectPostSaveRootContext &Other)
Definition ObjectSaveContext.h:561
bool IsCleanupRequired() const
Definition ObjectSaveContext.h:567
FObjectPostSaveRootContext(FObjectSaveContextData &InData)
Definition ObjectSaveContext.h:556
Definition ObjectSaveContext.h:244
FObjectPreSaveContext(const FObjectPreSaveContext &Other)
Definition ObjectSaveContext.h:252
FObjectPreSaveContext(FObjectSaveContextData &InData)
Definition ObjectSaveContext.h:246
EObjectSaveContextPhase GetPhase() const
Definition ObjectSaveContext.h:278
UE::Cook::ECookType GetCookType() const
Definition ObjectSaveContext.h:274
bool IsCookTypeUnknown() const
Definition ObjectSaveContext.h:273
FObjectSaveContextData & Data
Definition ObjectSaveContext.h:337
bool IsProceduralSave() const
Definition ObjectSaveContext.h:305
bool IsCookByTheBook() const
Definition ObjectSaveContext.h:271
bool IsUpdatingLoadedPath() const
Definition ObjectSaveContext.h:316
const TCHAR * GetTargetFilename() const
Definition ObjectSaveContext.h:263
bool IsFirstConcurrentSave() const
Definition ObjectSaveContext.h:325
const ITargetPlatform * GetTargetPlatform() const
Definition ObjectSaveContext.h:269
void AddSaveOverride(UObject *Target, FObjectSaveOverride InOverride)
Definition ObjectSaveContext.h:331
bool IsCooking() const
Definition ObjectSaveContext.h:266
UE::Cook::ECookingDLC GetCookingDLC() const
Definition ObjectSaveContext.h:275
bool IsFromAutoSave() const
Definition ObjectSaveContext.h:310
uint32 GetSaveFlags() const
Definition ObjectSaveContext.h:319
bool IsCookOnTheFly() const
Definition ObjectSaveContext.h:272
Definition ObjectSaveContext.h:535
void SetCleanupRequired(bool bCleanupRequired)
Definition ObjectSaveContext.h:548
FObjectPreSaveRootContext(const FObjectPreSaveRootContext &Other)
Definition ObjectSaveContext.h:542
FObjectPreSaveRootContext(FObjectSaveContextData &InData)
Definition ObjectSaveContext.h:537
Definition UnrealType.h:3087
Definition ObjectSaveContext.h:343
bool IsUpdatingLoadedPath() const
Definition ObjectSaveContext.h:442
UE::Cook::ECookType GetCookType() const
Definition ObjectSaveContext.h:371
bool IsFromAutoSave() const
Definition ObjectSaveContext.h:436
FObjectSavePackageSerializeContext(const FObjectSavePackageSerializeContext &Other)
Definition ObjectSaveContext.h:350
bool IsCooking() const
Definition ObjectSaveContext.h:363
FObjectSaveContextData & Data
Definition ObjectSaveContext.h:454
bool IsCookTypeUnknown() const
Definition ObjectSaveContext.h:370
FObjectSavePackageSerializeContext(FObjectSaveContextData &InData)
Definition ObjectSaveContext.h:345
EObjectSaveContextPhase GetPhase() const
Definition ObjectSaveContext.h:375
UE::Cook::ECookingDLC GetCookingDLC() const
Definition ObjectSaveContext.h:372
bool IsFirstConcurrentSave() const
Definition ObjectSaveContext.h:451
const ITargetPlatform * GetTargetPlatform() const
Definition ObjectSaveContext.h:366
const TCHAR * GetTargetFilename() const
Definition ObjectSaveContext.h:360
bool IsCookOnTheFly() const
Definition ObjectSaveContext.h:369
bool IsProceduralSave() const
Definition ObjectSaveContext.h:431
uint32 GetSaveFlags() const
Definition ObjectSaveContext.h:445
bool IsCookByTheBook() const
Definition ObjectSaveContext.h:368
Definition PackagePath.h:89
Definition PackageWriter.h:41
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition RefCounting.h:454
Definition Object.h:95
Definition Package.h:216
Definition CookOnTheFly.h:19
ECookingDLC
Definition CookEnums.h:19
ECookType
Definition CookEnums.h:12
Definition AdvancedWidgetsModule.cpp:13
Definition ObjectSaveContext.h:70
const ITargetPlatform * TargetPlatform
Definition ObjectSaveContext.h:109
TMap< UObject *, FObjectSaveOverride > SaveOverrides
Definition ObjectSaveContext.h:174
bool bCleanupRequired
Definition ObjectSaveContext.h:177
uint32 OriginalPackageFlags
Definition ObjectSaveContext.h:124
IPackageWriter * PackageWriter
Definition ObjectSaveContext.h:115
uint32 SaveFlags
Definition ObjectSaveContext.h:121
UE::Cook::ECookType CookType
Definition ObjectSaveContext.h:126
EObjectSaveContextPhase ObjectSaveContextPhase
Definition ObjectSaveContext.h:130
bool bSaveSucceeded
Definition ObjectSaveContext.h:153
bool bOuterConcurrentSave
Definition ObjectSaveContext.h:150
int32 NumRefPasses
Definition ObjectSaveContext.h:181
FString TargetFilename
Definition ObjectSaveContext.h:106
bool bProceduralSave
Definition ObjectSaveContext.h:137
bool bDeterminismDebug
Definition ObjectSaveContext.h:159
bool bUpdatingLoadedPath
Definition ObjectSaveContext.h:143
COREUOBJECT_API ~FObjectSaveContextData()
bool bRequestPostSaveSerialization
Definition ObjectSaveContext.h:187
UObject * Object
Definition ObjectSaveContext.h:118
COREUOBJECT_API FObjectSaveContextData(const FObjectSaveContextData &Other)
bool bBaseClassCalled
Definition ObjectSaveContext.h:184
COREUOBJECT_API FObjectSaveContextData()
UE::Cook::ICookInfo * CookInfo
Definition ObjectSaveContext.h:112
void AddSaveOverride(UObject *Target, FObjectSaveOverride InOverride)
Definition ObjectSaveContext.h:87
UE::Cook::ECookingDLC CookingDLC
Definition ObjectSaveContext.h:127
COREUOBJECT_API FObjectSaveContextData(FObjectSaveContextData &&Other)
Definition ObjectSaveOverride.h:28
Definition SoftObjectPath.h:56