UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DataflowTypePolicy.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Misc/TVariant.h"
7#include "UObject/Object.h"
8#include "Math/MathFwd.h"
10#include <string>
11
12class UObject;
13
14template<typename TType>
18
19namespace UE::Dataflow
20{
21 template<typename T>
23
24 template<typename T>
26 {
27 if (bAsArray)
28 {
29 return TDataflowPolicyTypeName<TArray<T>>::GetName();
30 }
32 }
33
34}
35
36
37// special version for void
38template<>
40{
41 static const TCHAR* GetName()
42 {
43 return TEXT("");
44 }
45};
46
47#define UE_DATAFLOW_MAKE_STRING(x) #x
48#define UE_DATAFLOW_POLICY_DECLARE_TYPENAME(TType) \
49template<> \
50struct TDataflowPolicyTypeName<TType> \
51{ \
52 static const TCHAR* GetName() \
53 { \
54 return TEXT(#TType); \
55 } \
56}; \
57template<> \
58struct TDataflowPolicyTypeName<TArray<TType>> \
59{ \
60 static const TCHAR* GetName() \
61 { \
62 return TEXT(UE_DATAFLOW_MAKE_STRING(TArray<TType>)); \
63 } \
64};
65
81
96
104
106{
107 virtual bool SupportsType(FName Type) const = 0;
108};
109
111{
112 virtual bool SupportsType(FName InType) const override
113 {
114 return true;
115 }
116
118 {
119 return true;
120 }
121
123 {
125 return &Instance;
126 }
127};
128
129template <typename T>
131{
132 using FType = T;
133
134 virtual bool SupportsType(FName InType) const override
135 {
137 }
138
140 {
141 return (InType == TypeName);
142 }
143
144 template <typename TVisitor>
146 {
147 if (RequestedType == TypeName)
148 {
150 Visitor(SingleTypePolicy);
151 return true;
152 }
153 return false;
154 }
155
157 {
159 return &Instance;
160 }
161
163};
164
165template <typename... TTypes>
167
168template <>
170{
171 virtual bool SupportsType(FName InType) const override
172 {
173 return false;
174 }
175
177 {
178 return false;
179 }
180
181 template <typename TVisitor>
183 {
184 return false;
185 }
186};
187
188template <typename T, typename... TTypes>
190{
192
193 virtual bool SupportsType(FName InType) const override
194 {
195 return SupportsTypeStatic(InType);
196 }
197
199 {
201 || Super::SupportsTypeStatic(InType);
202 }
203
204 template <typename TVisitor>
206 {
208 {
209 return true;
210 }
211 return Super::VisitPolicyByType(RequestedType, Visitor);
212 }
213
215 {
217 return &Instance;
218 }
219};
220
222{
223 static constexpr TCHAR ArrayPrefix[] = TEXT("TArray<");
224 static constexpr TCHAR ArrayFormat[] = TEXT("TArray<{0}>");
225
226 virtual bool SupportsType(FName InType) const override
227 {
229 }
230
232 {
233 return (InType.ToString().StartsWith(ArrayPrefix));
234 }
235
237 {
239 return &Instance;
240 }
241
243 {
245 {
247 const FString RightStr = InType.ToString().RightChop(ArrayPrefixLen);
248 check(!RightStr.IsEmpty() && RightStr[RightStr.Len() - 1] == '>');
249 return FName(RightStr.LeftChop(1)); // remove the last ">"
250 }
251 // not really an array just return the original type
252 return InType;
253 }
254
256 {
257 return FName(FString::Format(ArrayFormat, { InType.ToString() }));
258 }
259};
260
262 public TDataflowMultiTypePolicy<double, float, int64, uint64, int32, uint32, int16, uint16, int8, uint8>
263{
264};
265
267 public TDataflowMultiTypePolicy<TArray<double>, TArray<float>, TArray<int64>,
268 TArray<uint64>, TArray<int32>, TArray<uint32>, TArray<int16>, TArray<uint16>, TArray<int8>, TArray<uint8>>
269{
270};
271
273 public TDataflowMultiTypePolicy<FVector2D, FVector, FVector4, FVector2f, FVector3f, FVector4f, FQuat, FQuat4f, FLinearColor, FIntPoint, FIntVector, FIntVector4, FRotator>
274{
275};
276
278 public TDataflowMultiTypePolicy<TArray<FVector2D>, TArray<FVector>, TArray<FVector4>,
279 TArray<FVector2f>, TArray<FVector3f>, TArray<FVector4f>, TArray<FQuat>, TArray<FQuat4f>,
280 TArray<FLinearColor>, TArray<FIntPoint>, TArray<FIntVector>, TArray<FIntVector4>, TArray<FRotator>>
281{
282};
283
285 public TDataflowMultiTypePolicy<FString, FName, FText>
286{
287};
288
290 public TDataflowMultiTypePolicy<FDataflowTransformSelection, FDataflowVertexSelection, FDataflowFaceSelection, FDataflowGeometrySelection, FDataflowMaterialSelection, FDataflowCurveSelection>
291{
292};
293
295 public TDataflowMultiTypePolicy<TArray<FString>, TArray<FName>>
296{
297};
298
300 public TDataflowMultiTypePolicy<FVector, FQuat, FRotator>
301{
302};
303
312{
313 virtual bool SupportsType(FName InType) const override
314 {
316 }
317
319 {
320 return FDataflowStringTypePolicy::SupportsTypeStatic(InType)
321 || FDataflowNumericTypePolicy::SupportsTypeStatic(InType)
322 || FDataflowVectorTypePolicy::SupportsTypeStatic(InType)
325 ;
326 }
327
328 template <typename TVisitor>
330 {
331 return FDataflowStringTypePolicy::VisitPolicyByType(RequestedType, Visitor)
332 || FDataflowNumericTypePolicy::VisitPolicyByType(RequestedType, Visitor)
333 || FDataflowVectorTypePolicy::VisitPolicyByType(RequestedType, Visitor)
336 ;
337 }
338
344};
345
347{
348 virtual bool SupportsType(FName InType) const override
349 {
351 }
352
354 {
355 FString InnerTypeStr;
357 {
359 {
360 return true;
361 }
362 }
363 // not a proper object pointer
364 return false;
365 }
366
367 template <typename TVisitor>
369 {
371 {
373 Visitor(SingleTypePolicy);
374 return true;
375 }
376 return false;
377 }
378
384
385 // returns true if the type was a TObjectPtr and the inner type was properly extracted
386 static bool GetObjectPtrInnerType(const FString& InTypeStr, FString& InnerType)
387 {
388 static constexpr const TCHAR* ObjectPtrPrefix = TEXT("TObjectPtr<U");
389 static constexpr size_t ObjectPtrPrefixLen = std::char_traits<TCHAR>::length(ObjectPtrPrefix);
390 if (InTypeStr.StartsWith(ObjectPtrPrefix))
391 {
393 .RightChop(ObjectPtrPrefixLen) // remove the TObjectPtr< type
394 .LeftChop(1) // remove the last ">"
395 .TrimStartAndEnd();
396 return true;
397 }
398 return false;
399 }
400};
401
402// type Converters
403
404template <typename T>
406{
407 template <typename TFromType>
408 static void From(const TFromType& From, T& To) { To = From; }
409
410 template <typename TToType>
411 static void To(const T& From, TToType& To) { To = From; }
412};
413
414template<typename T>
416 requires(T t) {
417 static_cast<FString>(t.ToString());
418};
419
420
421template<typename T>
423 requires(T t, const FString& s ) {
424 static_cast<bool>(t.InitFromString(s));
425};
426
427template <>
428struct FDataflowConverter<FString>
429{
430 template <typename TFromType>
431 static void From(const TFromType& From, FString& To)
432 {
433 if constexpr (std::is_same_v<TFromType, FName>)
434 {
435 To = From.ToString();
436 }
437 else if constexpr (std::is_same_v<TFromType, FText>)
438 {
439 To = From.ToString();
440 }
441 else if constexpr (std::is_same_v<TFromType, bool>)
442 {
443 To = FString((From == true) ? "True" : "False");
444 }
445 else if constexpr (std::is_convertible_v<TFromType, double>)
446 {
447 To = FString::SanitizeFloat(double(From), 0);
448 }
449 else if constexpr (HasToStringMethod<TFromType>)
450 {
451 To = From.ToString();
452 }
453 else
454 {
455 To = From;
456 }
457 }
458
459 template <typename TToType>
460 static void To(const FString& From, TToType& To)
461 {
462 if constexpr (std::is_same_v<TToType, FName>)
463 {
464 To = FName(From);
465 }
466 else if constexpr (std::is_same_v<TToType, FText>)
467 {
469 }
470 else if constexpr (std::is_same_v<TToType, bool>)
471 {
472 To = From.ToBool();
473 }
474 else if constexpr (std::is_convertible_v<double, TToType>)
475 {
476 double Result = {0};
477 LexTryParseString(Result, *From);
478 To = Result;
479 }
480 else if constexpr (HasInitFromStringMethod<TToType>)
481 {
482 To.InitFromString(From);
483 }
484 else
485 {
486 To = From;
487 }
488 }
489};
490
491template <>
493{
494 template <typename TFromType>
495 static void From(const TFromType& From, FVector4& To)
496 {
497 if constexpr (std::is_same_v<TFromType, FVector2D> || std::is_same_v<TFromType, FVector2f>)
498 {
499 To = FVector4{ (double)From.X, (double)From.Y, 0, 0};
500 }
501 else if constexpr (std::is_same_v<TFromType, FVector> || std::is_same_v<TFromType, FVector3f>)
502 {
503 To = FVector4{ (double)From.X, (double)From.Y, (double)From.Z, 0 };
504 }
505 else if constexpr (std::is_same_v<TFromType, FVector4f>)
506 {
507 To = FVector4{ (double)From.X, (double)From.Y, (double)From.Z, (double)From.W };
508 }
509 else if constexpr (std::is_same_v<TFromType, FQuat4f> || std::is_same_v<TFromType, FQuat>)
510 {
511 To = FVector4{ (double)From.X, (double)From.Y, (double)From.Z, (double)From.W };
512 }
513 else if constexpr (std::is_same_v<TFromType, FLinearColor>)
514 {
515 To = FVector4 {(double)From.R, (double)From.G, (double)From.B, (double)From.A };
516 }
517 else if constexpr (std::is_same_v<TFromType, FIntVector3>)
518 {
519 To = FVector4 {(double)From.X, (double)From.Y, (double)From.Z, 0};
520 }
521 else if constexpr (std::is_same_v<TFromType, FIntVector4>)
522 {
523 To = FVector4 {(double)From.X, (double)From.Y, (double)From.Z, (double)From.W};
524 }
525 else if constexpr (std::is_same_v<TFromType, FIntPoint>)
526 {
527 To = FVector4 {(double)From.X, (double)From.Y, 0, 0};
528 }
529 else if constexpr (std::is_same_v<TFromType, FRotator>)
530 {
531 To = FVector4 {(double)From.Pitch, (double)From.Yaw, (double)From.Roll, 0};
532 }
533 else
534 {
535 To = From;
536 }
537 }
538
539 template <typename TToType>
540 static void To(const FVector4& From, TToType& To)
541 {
542 if constexpr (std::is_same_v<TToType, FVector2D>)
543 {
544 To = FVector2D{ From.X, From.Y };
545 }
546 else if constexpr (std::is_same_v<TToType, FVector2f>)
547 {
548 To = FVector2f{ (float)From.X, (float)From.Y };
549 }
550 else if constexpr (std::is_same_v<TToType, FVector>)
551 {
552 To = FVector{ From.X, From.Y, From.Z };
553 }
554 else if constexpr (std::is_same_v<TToType, FVector3f>)
555 {
556 To = FVector3f{ (float)From.X, (float)From.Y, (float)From.Z };
557 }
558 else if constexpr (std::is_same_v<TToType, FVector4f>)
559 {
560 To = FVector4f{ (float)From.X, (float)From.Y, (float)From.Z, (float)From.W };
561 }
562 else if constexpr (std::is_same_v<TToType, FQuat>)
563 {
564 To = FQuat{ From.X, From.Y, From.Z, From.W };
565 }
566 else if constexpr (std::is_same_v<TToType, FQuat4f>)
567 {
568 To = FQuat4f{ (float)From.X, (float)From.Y, (float)From.Z, (float)From.W };
569 }
570 else if constexpr (std::is_same_v<TToType, FLinearColor>)
571 {
572 To = FLinearColor{ (float)From.X, (float)From.Y, (float)From.Z, (float)From.W };
573 }
574 else if constexpr (std::is_same_v<TToType, FIntPoint>)
575 {
576 To = FIntPoint{ (int32)From.X, (int32)From.Y };
577 }
578 else if constexpr (std::is_same_v<TToType, FIntVector3>)
579 {
580 To = FIntVector3{ (int32)From.X, (int32)From.Y, (int32)From.Z };
581 }
582 else if constexpr (std::is_same_v<TToType, FIntVector4>)
583 {
584 To = FIntVector4{ (int32)From.X, (int32)From.Y, (int32)From.Z, (int32)From.W };
585 }
586 else if constexpr (std::is_same_v<TToType, FRotator>)
587 {
588 To = FRotator{ (double)From.X, (double)From.Y, (double)From.Z};
589 }
590 else
591 {
592 To = From;
593 }
594 }
595};
596
597template <>
599{
600 template <typename TFromType>
602 {
603 To.Initialize(From);
604 }
605
606 template <typename TToType>
607 static void To(const FDataflowSelection& From, TToType& To)
608 {
609 To.Initialize(From);
610 }
611};
612
613template <typename ArrayType>
614struct FDataflowConverter<TArray<ArrayType>>
615{
616 template <typename TFromType>
617 static void From(const TFromType& From, TArray<ArrayType>& To)
618 {
619 To.SetNum(From.Num());
620 for (int32 ArrayIndex = 0; ArrayIndex < From.Num(); ++ArrayIndex)
621 {
622 FDataflowConverter<ArrayType>::From(From[ArrayIndex], To[ArrayIndex]);
623 }
624 }
625
626 template <typename TToType>
627 static void To(const TArray<ArrayType>& From, TToType& To)
628 {
629 To.SetNum(From.Num());
630 for (int32 ArrayIndex = 0; ArrayIndex < From.Num(); ++ArrayIndex)
631 {
632 FDataflowConverter<ArrayType>::To(From[ArrayIndex], To[ArrayIndex]);
633 }
634 }
635};
636
637template <>
639{
640 template <typename TFromType>
641 static void From(const TFromType& From, FRotator& To)
642 {
643 if constexpr (std::is_same_v<TFromType, FQuat>)
644 {
645 To = FRotator(From);
646 }
647 else if constexpr (std::is_same_v<TFromType, FVector>)
648 {
650 }
651 else
652 {
653 To = From;
654 }
655 }
656
657 template <typename TToType>
658 static void To(const FRotator& From, TToType& To)
659 {
660 if constexpr (std::is_same_v<TToType, FQuat>)
661 {
663 }
664 else if constexpr (std::is_same_v<TToType, FVector>)
665 {
667 }
668 else
669 {
670 To = From;
671 }
672 }
673};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
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
#define UE_DATAFLOW_POLICY_DECLARE_TYPENAME(TType)
Definition DataflowTypePolicy.h:48
bool LexTryParseString(EBuildConfiguration &OutConfiguration, const TCHAR *Configuration)
Definition GenericPlatformMisc.cpp:270
UE::Math::TRotator< double > FRotator
Definition MathFwd.h:57
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
UObject * StaticFindFirstObject(UClass *Class, FStringView Name, EFindFirstObjectOptions Options, ELogVerbosity::Type AmbiguousMessageVerbosity, const TCHAR *InCurrentOperation)
Definition UObjectGlobals.cpp:669
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
Definition Text.h:385
static CORE_API FText FromString(const ANSICHAR *String)
Definition Text.cpp:1081
Definition Array.h:670
Definition Object.h:95
Definition DataflowTypePolicy.h:422
Definition DataflowTypePolicy.h:415
Definition DataflowAnyType.cpp:10
FName GetTypeName()
Definition DataflowTypePolicy.h:22
Definition DataflowTypePolicy.h:111
virtual bool SupportsType(FName InType) const override
Definition DataflowTypePolicy.h:112
static bool SupportsTypeStatic(FName InType)
Definition DataflowTypePolicy.h:117
static IDataflowTypePolicy * GetInterface()
Definition DataflowTypePolicy.h:122
Definition DataflowTypePolicy.h:222
static bool SupportsTypeStatic(FName InType)
Definition DataflowTypePolicy.h:231
static FName GetArrayType(FName InType)
Definition DataflowTypePolicy.h:255
static constexpr TCHAR ArrayFormat[]
Definition DataflowTypePolicy.h:224
static IDataflowTypePolicy * GetInterface()
Definition DataflowTypePolicy.h:236
virtual bool SupportsType(FName InType) const override
Definition DataflowTypePolicy.h:226
static constexpr TCHAR ArrayPrefix[]
Definition DataflowTypePolicy.h:223
static FName GetElementType(FName InType)
Definition DataflowTypePolicy.h:242
static void To(const FDataflowSelection &From, TToType &To)
Definition DataflowTypePolicy.h:607
static void From(const TFromType &From, FDataflowSelection &To)
Definition DataflowTypePolicy.h:601
static void From(const TFromType &From, FRotator &To)
Definition DataflowTypePolicy.h:641
static void To(const FRotator &From, TToType &To)
Definition DataflowTypePolicy.h:658
static void From(const TFromType &From, FString &To)
Definition DataflowTypePolicy.h:431
static void To(const FString &From, TToType &To)
Definition DataflowTypePolicy.h:460
static void From(const TFromType &From, FVector4 &To)
Definition DataflowTypePolicy.h:495
static void To(const FVector4 &From, TToType &To)
Definition DataflowTypePolicy.h:540
static void To(const TArray< ArrayType > &From, TToType &To)
Definition DataflowTypePolicy.h:627
static void From(const TFromType &From, TArray< ArrayType > &To)
Definition DataflowTypePolicy.h:617
Definition DataflowTypePolicy.h:406
static void To(const T &From, TToType &To)
Definition DataflowTypePolicy.h:411
static void From(const TFromType &From, T &To)
Definition DataflowTypePolicy.h:408
Definition DataflowSelection.h:147
Definition DataflowSelection.h:111
Definition DataflowSelection.h:123
Definition DataflowSelection.h:135
Definition DataflowTypePolicy.h:269
Definition DataflowTypePolicy.h:263
Definition DataflowTypePolicy.h:301
Definition DataflowTypePolicy.h:291
Definition DataflowSelection.h:13
Definition DataflowTypePolicy.h:296
Definition DataflowTypePolicy.h:312
static bool VisitPolicyByType(FName RequestedType, TVisitor Visitor)
Definition DataflowTypePolicy.h:329
static bool SupportsTypeStatic(FName InType)
Definition DataflowTypePolicy.h:318
virtual bool SupportsType(FName InType) const override
Definition DataflowTypePolicy.h:313
static IDataflowTypePolicy * GetInterface()
Definition DataflowTypePolicy.h:339
Definition DataflowTypePolicy.h:286
Definition DataflowSelection.h:85
Definition DataflowTypePolicy.h:347
virtual bool SupportsType(FName InType) const override
Definition DataflowTypePolicy.h:348
static bool VisitPolicyByType(FName RequestedType, TVisitor Visitor)
Definition DataflowTypePolicy.h:368
static bool SupportsTypeStatic(FName InType)
Definition DataflowTypePolicy.h:353
static IDataflowTypePolicy * GetInterface()
Definition DataflowTypePolicy.h:379
static bool GetObjectPtrInnerType(const FString &InTypeStr, FString &InnerType)
Definition DataflowTypePolicy.h:386
Definition DataflowTypePolicy.h:281
Definition DataflowTypePolicy.h:274
Definition DataflowSelection.h:98
Definition Color.h:48
Definition DataflowTypePolicy.h:106
virtual bool SupportsType(FName Type) const =0
static int32 Strlen(const CharType *String)
Definition CString.h:1047
virtual bool SupportsType(FName InType) const override
Definition DataflowTypePolicy.h:193
static bool SupportsTypeStatic(FName InType)
Definition DataflowTypePolicy.h:198
static IDataflowTypePolicy * GetInterface()
Definition DataflowTypePolicy.h:214
static bool VisitPolicyByType(FName RequestedType, TVisitor Visitor)
Definition DataflowTypePolicy.h:205
static bool SupportsTypeStatic(FName InType)
Definition DataflowTypePolicy.h:176
static bool VisitPolicyByType(FName RequestedType, TVisitor Visitor)
Definition DataflowTypePolicy.h:182
virtual bool SupportsType(FName InType) const override
Definition DataflowTypePolicy.h:171
Definition DataflowTypePolicy.h:166
static const TCHAR * GetName()
Definition DataflowTypePolicy.h:41
Definition DataflowTypePolicy.h:16
Definition DataflowTypePolicy.h:131
static IDataflowTypePolicy * GetInterface()
Definition DataflowTypePolicy.h:156
static bool SupportsTypeStatic(FName InType)
Definition DataflowTypePolicy.h:139
static const FName TypeName
Definition DataflowTypePolicy.h:162
T FType
Definition DataflowTypePolicy.h:132
static bool VisitPolicyByType(FName RequestedType, TVisitor Visitor)
Definition DataflowTypePolicy.h:145
virtual bool SupportsType(FName InType) const override
Definition DataflowTypePolicy.h:134
Definition ObjectPtr.h:488
Definition IntPoint.h:25
IntType X
Definition IntPoint.h:34
IntType X
Definition IntVector.h:31
IntType X
Definition IntVector.h:1225
static UE_FORCEINLINE_HINT TQuat< double > MakeFromRotator(const TRotator< double > &R)
Definition Quat.h:122
CORE_API TVector< T > Euler() const
Definition UnrealMath.cpp:1314
T X
Definition Quat.h:49
static CORE_API TRotator MakeFromEuler(const TVector< double > &Euler)
Definition UnrealMath.cpp:559
T X
Definition Vector2D.h:49
T X
Definition Vector4.h:43
T X
Definition Vector.h:62