UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MovieSceneEntityRange.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7
8template<typename... T> struct TTuple;
9
10namespace UE
11{
12namespace MovieScene
13{
14
15
16template<typename... T> struct TEntityPtr;
17template<typename... T> struct TEntityRangeImpl;
18
27template<typename... T>
28struct TEntityRange : TEntityRangeImpl<TMakeIntegerSequence<int, sizeof...(T)>, T...>
29{
30 using PtrType = TEntityPtr<T...>;
31 using Super = TEntityRangeImpl<TMakeIntegerSequence<int, sizeof...(T)>, T...>;
32
37 : Super(0)
38 {}
39
40
45 : Super(InNum)
46 {}
47
48
55
56
61 int32 Num() const
62 {
63 return this->NumEntities;
64 }
65
66
74 {
75 check(Index >= 0 && Index < this->NumEntities);
76 return TEntityPtr<T...>(Index, this);
77 }
78
79
83 template<int ComponentTypeIndex>
85 {
86 return this->ComponentArrays.template Get<ComponentTypeIndex>();
87 }
88
89
93 template<int ComponentTypeIndex>
94 auto* GetRawUnchecked() const
95 {
96 return this->ComponentArrays.template Get<ComponentTypeIndex>();
97 }
98
99
105 template<int32 ComponentTypeIndex>
106 auto GetAll() const
107 {
108 auto* Ptr = this->ComponentArrays.template Get<ComponentTypeIndex>();
109 return MakeArrayView(Ptr, Ptr ? this->NumEntities : 0);
110 }
111
112
120 template<int ComponentTypeIndex>
121 auto& GetComponent(int32 EntityIndex) const
122 {
123 auto* Ptr = this->ComponentArrays.template Get<ComponentTypeIndex>();
124 checkSlow(Ptr);
125 return *(Ptr + EntityIndex);
126 }
127
128
135 template<int ComponentTypeIndex>
136 auto* GetComponentOptional(int32 EntityIndex) const
137 {
138 auto* Ptr = this->ComponentArrays.template Get<ComponentTypeIndex>();
139 return Ptr ? (Ptr + EntityIndex) : nullptr;
140 }
141
142
149 template<int ComponentTypeIndex, typename ValueType>
150 void SetComponent(int32 EntityIndex, ValueType&& InValue) const
151 {
152 auto* Ptr = this->ComponentArrays.template Get<ComponentTypeIndex>();
153 checkSlow(Ptr);
154 *(Ptr + EntityIndex) = Forward<ValueType>(InValue);
155 }
156
157
158 /*~ stl-like range-for iterator */
159 TEntityPtr<T...> begin() const { return TEntityPtr<T...>(0, this); }
160 TEntityPtr<T...> end() const { return TEntityPtr<T...>(Num(), this); }
161};
162
163
167template<int... Indices, typename... T>
168struct TEntityRangeImpl<TIntegerSequence<int, Indices...>, T...>
169{
177 {
178 check(Index >= 0 && Index + NewNum <= NumEntities);
179
180 int Temp[] = {
181 ( (ComponentArrays.template Get<Indices>() ? (ComponentArrays.template Get<Indices>() = ComponentArrays.template Get<Indices>() + Index, 0) : 0), 0)...
182 };
183 (void)Temp;
184
185 NumEntities = NewNum;
186 }
187
188
189protected:
190
193 : NumEntities(InNum)
194 {}
195
198 : ComponentArrays(InBasePtrs...)
199 , NumEntities(InNum)
200 {}
201
204
207};
208
209
210
219template<typename... T>
221{
224 : Owner(InOwner)
225 , EntityIndex(InEntityIndex)
226 {
227 checkSlow(Owner != nullptr);
228 }
229
234 {
235 ++EntityIndex;
236 return *this;
237 }
238
239
244 {
245 --EntityIndex;
246 return *this;
247 }
248
253 {
254 return *this;
255 }
256
257
261 friend bool operator !=(const TEntityPtr& A, const TEntityPtr& B)
262 {
263 return A.EntityIndex != B.EntityIndex || A.Owner != B.Owner;
264 }
265
266
270 explicit operator bool() const
271 {
272 return EntityIndex >= 0 && EntityIndex < Owner->Num;
273 }
274
275
282 template<int ComponentTypeIndex>
283 auto& Get() const
284 {
285 return Owner->template GetComponent<ComponentTypeIndex>(EntityIndex);
286 }
287
288
295 template<int ComponentTypeIndex>
296 auto* GetOptional() const
297 {
298 return Owner->template GetComponentOptional<ComponentTypeIndex>(EntityIndex);
299 }
300
301
307 template<int ComponentTypeIndex, typename ValueType>
308 void Set(ValueType&& InValue) const
309 {
311 }
312
313
314private:
315
317 const TEntityRange<T...>* Owner;
318
320 int32 EntityIndex;
321};
322
323template<typename T>
324struct TEntityPtr<T>
325{
328 : Owner(InOwner)
329 , EntityIndex(InEntityIndex)
330 {
331 checkSlow(Owner != nullptr);
332 }
333
338 {
339 ++EntityIndex;
340 return *this;
341 }
342
343
348 {
349 --EntityIndex;
350 return *this;
351 }
352
357 {
358 return *this;
359 }
360
361
365 friend bool operator !=(const TEntityPtr& A, const TEntityPtr& B)
366 {
367 return A.EntityIndex != B.EntityIndex || A.Owner != B.Owner;
368 }
369
370
374 explicit operator bool() const
375 {
376 return EntityIndex >= 0 && EntityIndex < Owner->Num;
377 }
378
379
386 template<int ComponentTypeIndex>
387 auto& Get() const
388 {
389 return Owner->GetComponent<ComponentTypeIndex>(EntityIndex);
390 }
391
392
399 template<int ComponentTypeIndex>
400 auto* GetOptional() const
401 {
402 return Owner->GetComponentOptional<ComponentTypeIndex>(EntityIndex);
403 }
404
405
411 template<int ComponentTypeIndex, typename ValueType>
412 void Set(ValueType&& InValue) const
413 {
415 }
416
417
418private:
419
421 const TEntityRange<T>* Owner;
422
424 int32 EntityIndex;
425};
426
427
428} // namespace MovieScene
429} // namespace UE
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
constexpr auto MakeArrayView(OtherRangeType &&Other)
Definition ArrayView.h:873
#define checkSlow(expr)
Definition AssertionMacros.h:332
#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
typename UE4IntegerSequence_Private::TMakeIntegerSequenceImpl< T, N >::Type TMakeIntegerSequence
Definition IntegerSequence.h:31
const bool
Definition NetworkReplayStreaming.h:178
Definition MovieScene.Build.cs:6
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
Definition IntegerSequence.h:9
Definition Tuple.h:652
TEntityPtr & operator--()
Definition MovieSceneEntityRange.h:347
auto * GetOptional() const
Definition MovieSceneEntityRange.h:400
TEntityPtr(int32 InEntityIndex, const TEntityRange< T > *InOwner)
Definition MovieSceneEntityRange.h:327
TEntityPtr & operator++()
Definition MovieSceneEntityRange.h:337
void Set(ValueType &&InValue) const
Definition MovieSceneEntityRange.h:412
T & operator*()
Definition MovieSceneEntityRange.h:356
auto & Get() const
Definition MovieSceneEntityRange.h:387
Definition MovieSceneEntityRange.h:221
TEntityPtr & operator--()
Definition MovieSceneEntityRange.h:243
TEntityPtr(int32 InEntityIndex, const TEntityRange< T... > *InOwner)
Definition MovieSceneEntityRange.h:223
friend bool operator!=(const TEntityPtr &A, const TEntityPtr &B)
Definition MovieSceneEntityRange.h:261
auto * GetOptional() const
Definition MovieSceneEntityRange.h:296
TEntityPtr & operator*()
Definition MovieSceneEntityRange.h:252
TEntityPtr & operator++()
Definition MovieSceneEntityRange.h:233
void Set(ValueType &&InValue) const
Definition MovieSceneEntityRange.h:308
auto & Get() const
Definition MovieSceneEntityRange.h:283
void Slice(int32 Index, int32 NewNum)
Definition MovieSceneEntityRange.h:176
TEntityRangeImpl(int32 InNum, T *... InBasePtrs)
Definition MovieSceneEntityRange.h:197
TEntityRangeImpl(int32 InNum)
Definition MovieSceneEntityRange.h:192
TTuple< T *... > ComponentArrays
Definition MovieSceneEntityRange.h:203
Definition MovieSceneEntityRange.h:17
Definition MovieSceneEntityRange.h:29
int32 Num() const
Definition MovieSceneEntityRange.h:61
auto GetAll() const
Definition MovieSceneEntityRange.h:106
TEntityPtr< T... > operator[](int32 Index) const
Definition MovieSceneEntityRange.h:73
auto * GetComponentOptional(int32 EntityIndex) const
Definition MovieSceneEntityRange.h:136
void SetComponent(int32 EntityIndex, ValueType &&InValue) const
Definition MovieSceneEntityRange.h:150
TEntityPtr< T... > end() const
Definition MovieSceneEntityRange.h:160
TEntityPtr< T... > begin() const
Definition MovieSceneEntityRange.h:159
TEntityRange(int32 InNum)
Definition MovieSceneEntityRange.h:44
TEntityRange()
Definition MovieSceneEntityRange.h:36
auto & GetComponent(int32 EntityIndex) const
Definition MovieSceneEntityRange.h:121
auto *& GetComponentArrayReference()
Definition MovieSceneEntityRange.h:84
TEntityRange(int32 InNum, T *... InComponentArrays)
Definition MovieSceneEntityRange.h:52
auto * GetRawUnchecked() const
Definition MovieSceneEntityRange.h:94