UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Cache.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Core/Types.h"
5#include "HAL/Platform.h"
7
8namespace UE::CADKernel
9{
10template<class ObjectType>
12{
13protected:
14 ObjectType Value;
15 bool bReady;
16
17public:
19 : Value()
20 , bReady(false)
21 {
22 }
23
24 template<typename... InArgTypes>
25 TCache(InArgTypes&&... Args)
26 : Value(Forward<InArgTypes>(Args)...)
27 , bReady(true)
28 {
29 }
30
32 {
33 Ar << Cache.Value;
34 Ar << Cache.bReady;
35 return Ar;
36 }
37
38 void Set(const ObjectType& NewValue)
39 {
40 Value = NewValue;
41 bReady = true;
42 }
43
44 template<typename... InArgTypes>
45 void Set(InArgTypes&&... Args)
46 {
47 Value.Set(Forward<InArgTypes>(Args)...);
48 bReady = true;
49 }
50
51 void operator=(const ObjectType& NewValue)
52 {
53 Value = NewValue;
54 bReady = true;
55 }
56
57 void operator+=(const ObjectType& NewValue)
58 {
59 ensureCADKernel(bReady);
60 Value += NewValue;
61 }
62
63 ObjectType* operator->()
64 {
65 return &Value;
66 }
67
68 operator ObjectType& ()
69 {
70 return Value;
71 }
72
73 const ObjectType& operator*() const
74 {
75 return Value;
76 }
77
78 void SetReady()
79 {
80 bReady = true;
81 }
82
83 bool IsValid() const
84 {
85 return bReady;
86 }
87
88 void Empty()
89 {
90 bReady = false;
91 }
92};
93}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ensureCADKernel(InExpression)
Definition Types.h:115
return true
Definition ExternalRpcRegistry.cpp:601
Definition Archive.h:1208
Definition Cache.h:12
ObjectType * operator->()
Definition Cache.h:63
TCache(InArgTypes &&... Args)
Definition Cache.h:25
void SetReady()
Definition Cache.h:78
bool IsValid() const
Definition Cache.h:83
bool bReady
Definition Cache.h:15
TCache()
Definition Cache.h:18
void Set(const ObjectType &NewValue)
Definition Cache.h:38
ObjectType Value
Definition Cache.h:14
const ObjectType & operator*() const
Definition Cache.h:73
friend FArchive & operator<<(FArchive &Ar, TCache< ObjectType > &Cache)
Definition Cache.h:31
void operator=(const ObjectType &NewValue)
Definition Cache.h:51
void Empty()
Definition Cache.h:88
void operator+=(const ObjectType &NewValue)
Definition Cache.h:57
void Set(InArgTypes &&... Args)
Definition Cache.h:45
Definition CADEntity.cpp:23
@ false
Definition radaudio_common.h:23