UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMContentScope.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 "CoreTypes.h"
8#include "Logging/LogMacros.h"
10#include "UObject/GCObject.h"
13
14#define UE_API COREUOBJECT_API
15
16class UObject;
17enum EObjectFlags;
19
21
23
24namespace Verse
25{
26struct VTaskGroup;
27}
28
29namespace verse
30{
31
32class task_group;
33
35{
36public:
41
42 virtual ~FContentScope() {}
43
45 bool WasTerminated() const { return bTerminated; }
46
48 const UObject* GetWorldContext() const { return InstantiationOuter.Get(); }
49
50#if WITH_VERSE_BPVM
51 virtual verse::task_group* GetTaskGroup() = 0;
52#else
53 virtual Verse::VTaskGroup* GetTaskGroup() = 0;
54#endif
55
56 virtual bool HasActiveTasks() const = 0;
57 virtual void Terminate() = 0;
58 virtual void ResetTerminationState() = 0;
59
60 virtual bool ReserveActorFromQuota() = 0;
61 virtual bool CanReserveActorFromQuota() const = 0;
62 virtual void ReleaseActorToQuota() = 0;
63
64 virtual bool HasContent() const = 0;
65
66 UE_API FString GetCreatorDebugName() const;
69
70 // FORT-687867: Delete this when tag query code is fixed. It depends on the content scope actor and they should not
71 // See TagQueryUtils::GetActorFromActiveVerseExecutionContentScope()
72 void SetOwner(const UObject* InOwner) { Owner = InOwner; }
73 const UObject* GetOwner() const { return Owner.Get(); }
74
75 // Called whenever the content scope is cleaned up/terminated (either normally or abnormally)
76 // If it was terminated abnormally, 'true' is passed to the callback
77 // All registered callbacks are removed after the event is broadcast
79
80protected:
81 // FORT-687867: Delete this when tag query code is fixed. It depends on the content scope actor and they should not
82 // See TagQueryUtils::GetActorFromActiveVerseExecutionContentScope()
84
86
88 bool bTerminated = false;
89};
90
92{
93public:
96
99
100 static bool IsActive() { return GetActiveScopeGuard() != nullptr; }
101 static const TSharedRef<FContentScope>& GetActiveScope() { return GetActiveScopeGuard()->ContentScope; }
102
104
105 // If there is an active content scope, enqueues Callback to be called when the last active content scope is popped from the stack.
106 // IF there is no active content scope, calls Callback immediately.
107 static UE_API void OnInactive(TFunction<void()>&& Callback);
108
110
111private:
112 static UE_API FContentScopeGuard*& GetActiveScopeGuard();
113 static UE_API FContentScopeGuard* GetRootScopeGuard();
114
115 UE_API bool EnforceExecutionTime();
116
117 TSharedRef<FContentScope> ContentScope;
118 FContentScopeGuard* Parent = nullptr;
119
120 // Scheduled for shutdown when the outermost scope guard ends.
121 TArray<TFunction<void()>> PendingOnInactiveCallbacks;
122};
123
126
127} // namespace verse
128
129#undef UE_API
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
EObjectFlags
Definition ObjectMacros.h:552
#define UE_API
Definition SColorGradingComponentViewer.h:12
#define UE_API
Definition VVMContentScope.h:14
Definition UObjectGlobals.h:2492
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SharedPointer.h:153
Definition Object.h:95
Definition VVMContentScope.h:92
static UE_API bool EnforceExecutionTimeForActiveContentScope()
Definition VVMContentScope.cpp:100
static const TSharedRef< FContentScope > & GetActiveScope()
Definition VVMContentScope.h:101
FContentScopeGuard(const FContentScopeGuard &)=delete
static UE_API void ScheduleTerminateContentScope(TSharedRef< FContentScope > ContentScope)
Definition VVMContentScope.cpp:81
static bool IsActive()
Definition VVMContentScope.h:100
static UE_API void OnInactive(TFunction< void()> &&Callback)
Definition VVMContentScope.cpp:88
FContentScopeGuard & operator=(const FContentScopeGuard &)=delete
UE_API ~FContentScopeGuard()
Definition VVMContentScope.cpp:54
Definition VVMContentScope.h:35
virtual void Terminate()=0
virtual void ResetTerminationState()=0
const UObject * GetInstantiationOuter() const
Definition VVMContentScope.h:47
virtual void ReleaseActorToQuota()=0
virtual Verse::VTaskGroup * GetTaskGroup()=0
UE_API void SetCreatorDebugNameFromObject(const UObject *Object)
Definition VVMContentScope.cpp:23
UE_API FString GetCreatorDebugName() const
Definition VVMContentScope.cpp:35
UE_API void SetCreatorDebugName(const FStringView &InCreatorDebugName)
Definition VVMContentScope.cpp:15
virtual ~FContentScope()
Definition VVMContentScope.h:42
const UObject * GetWorldContext() const
Definition VVMContentScope.h:48
virtual bool HasContent() const =0
virtual bool CanReserveActorFromQuota() const =0
FString CreatorDebugName
Definition VVMContentScope.h:85
const UObject * GetOwner() const
Definition VVMContentScope.h:73
bool WasTerminated() const
Definition VVMContentScope.h:45
TWeakObjectPtr< const UObject > InstantiationOuter
Definition VVMContentScope.h:87
virtual bool ReserveActorFromQuota()=0
bool ShouldExecuteCodeWithThisScope() const
Definition VVMContentScope.h:44
FContentScopeCleanupSignature OnContentScopeCleanup
Definition VVMContentScope.h:78
void SetOwner(const UObject *InOwner)
Definition VVMContentScope.h:72
FContentScope(const UObject *InInstantiationOuter)
Definition VVMContentScope.h:37
TWeakObjectPtr< const UObject > Owner
Definition VVMContentScope.h:83
bool bTerminated
Definition VVMContentScope.h:88
virtual bool HasActiveTasks() const =0
Definition Archive.h:36
Definition VVMContentScope.cpp:14
UObject * GetInstantiationOuter()
Definition VVMContentScope.cpp:141
EObjectFlags GetInstantiationFlags()
Definition VVMContentScope.cpp:155
Definition WeakObjectPtrTemplates.h:25
FORCEINLINE T * Get(bool bEvenIfPendingKill) const
Definition WeakObjectPtrTemplates.h:132