UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMAbstractVisitor.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_VERSE_VM || defined(__INTELLISENSE__)
6
7#include "CoreTypes.h"
10#include "VVMCell.h"
11#include "VVMValue.h"
12#include "VVMWriteBarrier.h"
13
14class UObject;
15
16namespace Verse
17{
18
19struct VNativeStruct;
20
22{
24
25 static constexpr bool bIsAbstractVisitor = true;
26
27 // A stack based context to maintain the chain of referrers
28 struct FReferrerContext
29 {
32
33 FReferenceToken GetReferrer() const { return Referrer; }
34 FReferrerContext* GetPrevious() const { return Previous; }
35
36 private:
40 };
41
42 virtual ~FAbstractVisitor() = default;
43
44 // The context provides information about the current cell being visited
45 FReferrerContext* GetContext() const
46 {
47 return Context;
48 }
49
50 // Canonical visit methods. Visitors should override these for the types they care about.
51
52 virtual void VisitNonNull(VCell* InCell, const TCHAR* ElementName) = 0;
53 virtual void VisitNonNull(UObject* InObject, const TCHAR* ElementName) = 0;
54 virtual void VisitAuxNonNull(void* InAux, const TCHAR* ElementName) = 0;
55
56 // Convenience methods. These forward to the canonical methods above.
57
58 COREUOBJECT_API void Visit(VCell* InCell, const TCHAR* ElementName);
59 COREUOBJECT_API void Visit(UObject* InObject, const TCHAR* ElementName);
60 COREUOBJECT_API void VisitAux(void* InAux, const TCHAR* ElementName);
61
62 COREUOBJECT_API void Visit(VValue Value, const TCHAR* ElementName);
63
64 template <typename T>
65 void Visit(TWriteBarrier<T>& Value, const TCHAR* ElementName)
66 {
67 Visit(Value.Get(), ElementName);
68 }
69
70 template <typename T>
71 void Visit(T& Value, const TCHAR* ElementName);
72
73 // Simple arrays
74 template <typename T>
75 void Visit(T Begin, T End, const TCHAR* ElementName);
76
77 template <typename T>
78 void Visit(T* Values, uint64 Count, const TCHAR* ElementName)
79 {
80 Visit(Values, Values + Count, ElementName);
81 }
82
83 // Arrays
84 template <typename ElementType, typename AllocatorType>
85 void Visit(TArray<ElementType, AllocatorType>& Values, const TCHAR* ElementName);
86
87 // Sets
88 template <typename ElementType, typename KeyFuncs, typename Allocator>
89 void Visit(TSet<ElementType, KeyFuncs, Allocator>& Values, const TCHAR* ElementName);
90
91 // Maps
92 template <typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
93 void Visit(TMap<KeyType, ValueType, SetAllocator, KeyFuncs>& Values, const TCHAR* ElementName);
94
95 // Mimic FMarkStackVisitor so VisitReferencesImpl can call these unconditionally.
96
97 virtual bool IsMarked(VCell* InCell, const TCHAR* ElementName) = 0;
98 virtual void ReportNativeBytes(size_t Bytes) = 0;
100
101 // Mimic FStructuredArchiveVisitor so Visit overloads can call these unconditionally.
102
103 void Visit(uint8 Value, const TCHAR* ElementName) {}
104 void Visit(uint32 Value, const TCHAR* ElementName) {}
105
106protected:
107 FAbstractVisitor() = default;
108
109private:
110 FReferrerContext* Context{nullptr};
111};
112
113} // namespace Verse
114#endif // WITH_VERSE_VM
#define UE_NONCOPYABLE(TypeName)
Definition CoreMiscDefines.h:457
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
decltype(auto) Visit(Func &&Callable, Variants &&... Args)
Definition TVariant.h:271
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition Object.h:95
@ Visitor
Definition XmppMultiUserChat.h:94
Definition Archive.h:36
Definition ReferenceToken.h:44