UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MovieSceneIntermediatePropertyValue.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Misc/InlineValue.h"
7
8
9/*~
10 * These classes provide a way to pass around type-erased values for properties within Sequencer
11 * Two types are provided to distinguish between values intended as 'source' data (ie, actual property data on a UObject),
12 * and intermediate data used by Sequencer for computational purposes at compile time. In this way it is possible to
13 * write generic property code and APIs without needing to know the specifics of the type being represented.
14 */
15
16namespace UE::MovieScene
17{
18
19struct FSourcePropertyValue;
20struct FIntermediatePropertyValue;
21struct FIntermediatePropertyValueConstRef;
22
23namespace Private
24{
25 /*
26 * Base class for all type-erased intermediate and source value types
27 */
29 {
31
35
36 virtual const void* Get() const = 0;
37 };
38
39
40 /*
41 * Base class for all value-storage type-erased intermediate and source value types
42 */
51
52
53 /*
54 * Class that holds a void* pointer to a value and is able to return it
55 */
57 {
59 : Value(In)
60 {
61 this->SizeofT = InSize;
62 }
63 const void* Get() const override
64 {
65 return Value;
66 }
67 protected:
68 const void* Value;
69 };
70
71 /*
72 * Class that holds a typed value and is able to return and copy it
73 */
74 template<typename T>
76 {
77 template<typename U>
79 : Value(Forward<U>(In))
80 {
81 this->SizeofT = sizeof(U);
82 }
87 const void* Get() const override
88 {
89 return &Value;
90 }
91 private:
92 T Value;
93 };
94
95 /*
96 * Class that holds a pointer to a value and is able to return and copy it
97 */
98 template<typename T>
100 {
102 : Value(In)
103 {
104 this->SizeofT = sizeof(T);
105 }
112 const void* Get() const override
113 {
114 return Value;
115 }
116 protected:
118 };
119
120} // namespace Private
121
122
123
124
131{
132 /*
133 * Default constructor
134 */
136 {
137 }
138
139 /*
140 * Move construction/assignment
141 */
144
145 /*
146 * Check if this value is assigned a valid value
147 * @return true if this value is valid, false otherwise
148 */
149 explicit operator bool() const
150 {
151 return Value.IsValid();
152 }
153
154 /*
155 * Create a new FSourcePropertyValue from a memory address and a reflected property that corresponds to the address
156 *
157 * @param Ptr The value pointer to create this source value from
158 * @param Property The property that corresponds to the memory addres
159 * @return A new source value
160 */
169
170
171 /*
172 * Create a new FSourcePropertyValue from a typed value
173 *
174 * @param Value The value to create this source value from
175 * @return A new source value
176 */
177 template<typename T>
186
187 /*
188 * Retrieve the memory address of the wrapped source value
189 */
190 const void* Get() const
191 {
192 return Value.IsValid() ? Value->Get() : nullptr;
193 }
194
195
196 /*
197 * Cast this source value to another type, assuming the underlying type matches.
198 * @note: Only crude type-checking is performed here: it is the callee's responsibility to ensure the cast is valid
199 */
200 template<typename T>
201 const T* Cast() const
202 {
203 const T* Address = static_cast<const T*>(Get());
204
205 check(!Address || Value->SizeofT == sizeof(T));
206 return Address;
207 }
208
209private:
210
212 : Value(MoveTemp(InValue))
213 {
214 }
215
217};
218
219
220
221
228{
232 template<typename T, typename = std::enable_if_t<!std::is_same_v<T, void>>> // Disabled for void*
234 : Value(Private::TTypeErasedPropertyPtrImpl<const T>(Ptr))
235 {
236 }
237
238
242 template<typename T>
244 : Value(Private::TTypeErasedPropertyValueImpl<T>(Forward<T>(InValue)))
245 {
246 }
247
248
254
255
261
262
267
268
269 /*
270 * Retrieve the address of this value
271 */
272 const void* Get() const
273 {
274 return Value->Get();
275 }
276
277
278 /*
279 * Cast this value to another type, assuming the underlying type matches.
280 * @note: Only crude type-checking is performed here: it is the callee's responsibility to ensure the cast is valid
281 */
282 template<typename T>
283 const T* Cast() const
284 {
285 check(Value->SizeofT == sizeof(T));
286
287 const T* Address = static_cast<const T*>(Get());
288 return Address;
289 }
290
291protected:
292
296
301
303};
304
305
306
307
312{
318
324
325
326 /*
327 * Create a new FIntermediatePropertyValue from a typed value
328 *
329 * @param Value The value to create this source value from
330 * @return A new intermediate value
331 */
332 template<typename T>
341
342
343 /*
344 * Create a new FIntermediatePropertyValue from an address to a value
345 *
346 * @param Ptr The address of the value to wrap
347 * @return A new intermediate value
348 */
349 template<typename T, typename = std::enable_if_t<!std::is_same_v<T, void>>> // Disabled for void*
358
359
360 /*
361 * Create a copy of this value
362 */
364 {
365 return FIntermediatePropertyValue(Value->Copy());
366 }
367
368 // elevate const overloads
371
372
373 /*
374 * Retrieve this value's underlying address
375 */
376 void* Get()
377 {
378 return const_cast<void*>(Value->Get());
379 }
380
381
382 /*
383 * Cast this value to another type, assuming the underlying type matches.
384 * @note: Only crude type-checking is performed here: it is the callee's responsibility to ensure the cast is valid
385 */
386 template<typename T>
387 T* Cast()
388 {
389 check(Value->SizeofT == sizeof(T));
390
391 T* Address = static_cast<T*>(Get());
392 return Address;
393 }
394
395protected:
397
402};
403
408
409} // namespace UE::MovieScene
410
411
#define check(expr)
Definition AssertionMacros.h:314
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
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition UnrealType.h:174
Definition InlineValue.h:22
Definition OverriddenPropertySet.cpp:45
Definition ConstraintsManager.h:14
UE::Core::Private::Decay::TDecayNonReference< typenameTRemoveReference< T >::Type >::Type Type
Definition Decay.h:45
Definition MovieSceneIntermediatePropertyValue.h:228
const void * Get() const
Definition MovieSceneIntermediatePropertyValue.h:272
FIntermediatePropertyValueConstRef(TInlineValue< Private::ITypeErasedPropertyValueImpl > &&InValue)
Definition MovieSceneIntermediatePropertyValue.h:297
FIntermediatePropertyValueConstRef(T &&InValue)
Definition MovieSceneIntermediatePropertyValue.h:243
const T * Cast() const
Definition MovieSceneIntermediatePropertyValue.h:283
TInlineValue< Private::ITypeErasedPropertyValueImpl > Value
Definition MovieSceneIntermediatePropertyValue.h:302
FIntermediatePropertyValueConstRef(const T *Ptr)
Definition MovieSceneIntermediatePropertyValue.h:233
FIntermediatePropertyValueConstRef & operator=(const FIntermediatePropertyValueConstRef &)=delete
FIntermediatePropertyValueConstRef(FIntermediatePropertyValueConstRef &&)=default
FIntermediatePropertyValue Copy() const
Definition MovieSceneIntermediatePropertyValue.h:404
FIntermediatePropertyValueConstRef()
Definition MovieSceneIntermediatePropertyValue.h:293
FIntermediatePropertyValueConstRef & operator=(FIntermediatePropertyValueConstRef &&)=default
FIntermediatePropertyValueConstRef(const FIntermediatePropertyValueConstRef &)=delete
Definition MovieSceneIntermediatePropertyValue.h:312
void * Get()
Definition MovieSceneIntermediatePropertyValue.h:376
T * Cast()
Definition MovieSceneIntermediatePropertyValue.h:387
static FIntermediatePropertyValue FromAddress(T *Ptr)
Definition MovieSceneIntermediatePropertyValue.h:350
FIntermediatePropertyValue & operator=(const FIntermediatePropertyValue &)=delete
FIntermediatePropertyValue(FIntermediatePropertyValue &&)=default
static FIntermediatePropertyValue FromValue(T &&In)
Definition MovieSceneIntermediatePropertyValue.h:333
friend FIntermediatePropertyValueConstRef
Definition MovieSceneIntermediatePropertyValue.h:396
FIntermediatePropertyValue Copy() const
Definition MovieSceneIntermediatePropertyValue.h:363
FIntermediatePropertyValue(const FIntermediatePropertyValue &)=delete
FIntermediatePropertyValue & operator=(FIntermediatePropertyValue &&)=default
FIntermediatePropertyValue(TInlineValue< Private::ITypeErasedPropertyValueImpl > &&InValue)
Definition MovieSceneIntermediatePropertyValue.h:398
Definition MovieSceneIntermediatePropertyValue.h:131
const T * Cast() const
Definition MovieSceneIntermediatePropertyValue.h:201
FSourcePropertyValue()
Definition MovieSceneIntermediatePropertyValue.h:135
static FSourcePropertyValue FromAddress(const void *Ptr, const FProperty &Property)
Definition MovieSceneIntermediatePropertyValue.h:161
static FSourcePropertyValue FromValue(T &&Value)
Definition MovieSceneIntermediatePropertyValue.h:178
const void * Get() const
Definition MovieSceneIntermediatePropertyValue.h:190
FSourcePropertyValue & operator=(FSourcePropertyValue &&)=default
FSourcePropertyValue(FSourcePropertyValue &&)=default
Definition MovieSceneIntermediatePropertyValue.h:57
FTypeErasedConstPropertyPtrBase(const void *In, int32 InSize)
Definition MovieSceneIntermediatePropertyValue.h:58
const void * Get() const override
Definition MovieSceneIntermediatePropertyValue.h:63
const void * Value
Definition MovieSceneIntermediatePropertyValue.h:68
Definition MovieSceneIntermediatePropertyValue.h:29
int32 SizeofT
Definition MovieSceneIntermediatePropertyValue.h:30
virtual ~ITypeErasedPropertyConstValueImpl()
Definition MovieSceneIntermediatePropertyValue.h:32
Definition MovieSceneIntermediatePropertyValue.h:44
virtual ~ITypeErasedPropertyValueImpl()
Definition MovieSceneIntermediatePropertyValue.h:45
virtual TInlineValue< ITypeErasedPropertyValueImpl > Copy() const =0
Definition MovieSceneIntermediatePropertyValue.h:100
TInlineValue< ITypeErasedPropertyValueImpl > Copy() const override
Definition MovieSceneIntermediatePropertyValue.h:106
const void * Get() const override
Definition MovieSceneIntermediatePropertyValue.h:112
T * Value
Definition MovieSceneIntermediatePropertyValue.h:117
TTypeErasedPropertyPtrImpl(T *In)
Definition MovieSceneIntermediatePropertyValue.h:101
Definition MovieSceneIntermediatePropertyValue.h:76
TTypeErasedPropertyValueImpl(U &&In)
Definition MovieSceneIntermediatePropertyValue.h:78
TInlineValue< ITypeErasedPropertyValueImpl > Copy() const override
Definition MovieSceneIntermediatePropertyValue.h:83
const void * Get() const override
Definition MovieSceneIntermediatePropertyValue.h:87