UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SplineTypeId.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
7namespace UE
8{
9namespace Geometry
10{
11namespace Spline
12{
13
16template<typename T>
17struct TDependentFalse : std::false_type {};
18
19template<typename T>
21{
22 // Static assert ensures custom types define their name
23 static_assert(TDependentFalse<T>::value,
24 "Splines must specialize TSplineValueTypeTraits<T> with a static 'Name' member.");
25};
30{
31public:
32 // Type ID type (32-bit for all types)
33 using IdType = uint32;
34
43 static constexpr IdType GenerateTypeId(
44 const TCHAR* ImplName,
45 const TCHAR* ValueTypeName)
46 {
47 // Compute hash values from the strings (16 bits each)
50
51 // Combine: [implHash(16) | valueHash(16)]
52 return ((IdType)ImplHash << 16) | ValueHash;
53 }
54
59 static constexpr uint32 CompileTimeHash(const TCHAR* Str)
60 {
61 uint32 Result = 2166136261u; // FNV offset basis
62
63 while (*Str)
64 {
65 // Process one TCHAR at a time
66 TCHAR C = *Str++;
67
68 // FNV-1a hash
69 Result ^= (uint32)C;
70 Result *= 16777619u; // FNV prime
71 }
72
73 return Result;
74 }
75
79 static constexpr uint16 GetImplHash(IdType TypeId)
80 {
81 return (TypeId >> 16) & 0xFFFF; // Upper 16 bits
82 }
83
87 static constexpr uint16 GetValueHash(IdType TypeId)
88 {
89 return TypeId & 0xFFFF; // Lower 16 bits
90 }
91
96 static bool CheckTypeIdConflict(IdType TypeId, const FString& ImplName, const FString& ValueTypeName,
97 const FString& ExistingImplName, const FString& ExistingValueTypeName)
98 {
99 // If the names don't match but the TypeId does, we have a hash collision
102
104 {
105 UE_LOG(LogSpline, Error, TEXT(" HASH COLLISION in SplineTypeId!! ️"));
106 UE_LOG(LogSpline, Error, TEXT(" TypeId: 0x%08X"), TypeId);
107 UE_LOG(LogSpline, Error, TEXT(" Attempted registration: Impl=%s, Value=%s"),
109 UE_LOG(LogSpline, Error, TEXT(" Existing registration: Impl=%s, Value=%s"),
111 return true;
112 }
113
114 return false;
115 }
116};
117
118// Simplified macro to declare a static type ID in a spline class
119#define DECLARE_SPLINE_TYPE_ID(ImplName, ValueTypeName) \
120 static const FSplineTypeId::IdType& GetStaticTypeId() \
121 { \
122 static const FSplineTypeId::IdType CachedTypeId = \
123 FSplineTypeId::GenerateTypeId(ImplName, ValueTypeName); \
124 return CachedTypeId; \
125 } \
126 virtual FSplineTypeId::IdType GetTypeId() const override \
127 { \
128 return GetStaticTypeId(); \
129 } \
130 static FString GetSplineTypeName() \
131 { \
132 return FString(ImplName); \
133 } \
134 virtual FString GetImplementationName() const override \
135 { \
136 return FString(ImplName); \
137 }
138
139} // namespace Spline
140} // namespace Geometry
141} // namespace UE
#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
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DEFINE_LOG_CATEGORY_STATIC(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:380
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition SplineTypeId.h:30
static constexpr uint16 GetValueHash(IdType TypeId)
Definition SplineTypeId.h:87
static bool CheckTypeIdConflict(IdType TypeId, const FString &ImplName, const FString &ValueTypeName, const FString &ExistingImplName, const FString &ExistingValueTypeName)
Definition SplineTypeId.h:96
uint32 IdType
Definition SplineTypeId.h:33
static constexpr uint32 CompileTimeHash(const TCHAR *Str)
Definition SplineTypeId.h:59
static constexpr IdType GenerateTypeId(const TCHAR *ImplName, const TCHAR *ValueTypeName)
Definition SplineTypeId.h:43
static constexpr uint16 GetImplHash(IdType TypeId)
Definition SplineTypeId.h:79
Definition AdvancedWidgetsModule.cpp:13
Definition SplineTypeId.h:17