UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BulkDataBuffer.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
14template<typename DataType>
16{
17public:
19
21 FBulkDataBuffer() = default;
22
31 {
32 *this = Other;
33 }
34
41 {
42 View = Other.View;
43 Other.View = ViewType();
44 }
45
55
58 {
59 FreeBuffer();
60 }
61
70 {
71 FreeBuffer();
72
73 if (this != &Other)
74 {
75 const int64 BufferSize = Other.View.Num();
76
77 DataType* BufferCopy = (DataType*)FMemory::Malloc(BufferSize);
78 FMemory::Memcpy(BufferCopy, Other.View.GetData(), BufferSize);
79
80 View = ViewType(BufferCopy, BufferSize);
81 }
82
83 return *this;
84 }
85
92 {
93 if (this != &Other)
94 {
95 FreeBuffer();
96
97 View = Other.View;
98 Other.View = ViewType();
99 }
100
101 return *this;
102 }
103
108 void Empty()
109 {
110 FreeBuffer();
111
112 View = ViewType();
113 }
114
123 {
124 FreeBuffer();
125
127 }
128
133 const ViewType& GetView() const
134 {
135 return View;
136 }
137
138private:
139
140 void FreeBuffer()
141 {
142 if (View.GetData() != nullptr)
143 {
144 FMemory::Free(View.GetData());
145 }
146 }
147
148 ViewType View;
149};
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
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
Definition BulkDataBuffer.h:16
FBulkDataBuffer & operator=(const FBulkDataBuffer &Other)
Definition BulkDataBuffer.h:69
TArrayView64< DataType > ViewType
Definition BulkDataBuffer.h:18
FBulkDataBuffer(DataType *InBuffer, int64 InNumberOfElements)
Definition BulkDataBuffer.h:50
const ViewType & GetView() const
Definition BulkDataBuffer.h:133
FBulkDataBuffer(const FBulkDataBuffer &Other)
Definition BulkDataBuffer.h:30
void Reset(DataType *InBuffer, uint64 InNumberOfElements)
Definition BulkDataBuffer.h:122
void Empty()
Definition BulkDataBuffer.h:108
FBulkDataBuffer(FBulkDataBuffer &&Other)
Definition BulkDataBuffer.h:40
~FBulkDataBuffer()
Definition BulkDataBuffer.h:57
FBulkDataBuffer()=default
static FORCENOINLINE CORE_API void Free(void *Original)
Definition UnrealMemory.cpp:685
static UE_FORCEINLINE_HINT void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
Definition UnrealMemory.h:160