Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
CompressedGrowableBuffer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Containers/Array.h"
7#include "UObject/NameTypes.h"
8
9/**
10 * Growable compressed buffer. Usage is to append frequently but only request and therefore decompress
11 * very infrequently. The prime usage case is the memory profiler keeping track of full call stacks.
12 */
14{
15private:
16 /**
17 * This enum and the following constructor is a workaround for VC compiler bug that prevents using attributes
18 * on constructors without inline implementation. This should be removed when the deprecated ctor is removed.
19 */
21 {
23 };
24 FCompressedGrowableBuffer(EVS2015Redirector, int32 MaxPendingBufferSize, ECompressionFlags CompressionFlags);
25public:
26 /**
27 * Constructor
28 *
29 * @param MaxPendingBufferSize Max chunk size to compress in uncompressed bytes
30 * @param CompressionFlags Compression flags to compress memory with
31 */
32 UE_DEPRECATED(4.21, "Use FName version of FCompressedGrowableBuffer constructor")
33 FCompressedGrowableBuffer(int32 MaxPendingBufferSize, ECompressionFlags CompressionFlags)
34 // Make sure to remove the EVS2015Redirector constructor when this constructor is removed
35 : FCompressedGrowableBuffer(EVS2015Redirector::Redirect, MaxPendingBufferSize, CompressionFlags)
36 {}
37 FCompressedGrowableBuffer(int32 MaxPendingBufferSize, FName COmpressionFormat, ECompressionFlags CompressionFlags=COMPRESS_None);
38
39 /**
40 * Locks the buffer for reading. Needs to be called before calls to Access and needs
41 * to be matched up with Unlock call.
42 */
43 void Lock();
44 /**
45 * Unlocks the buffer and frees temporary resources used for accessing.
46 */
47 void Unlock();
48
49 /**
50 * Appends passed in data to the buffer. The data needs to be less than the max
51 * pending buffer size. The code will assert on this assumption.
52 *
53 * @param Data Data to append
54 * @param Size Size of data in bytes.
55 * @return Offset of data, used for retrieval later on
56 */
57 int32 Append( void* Data, int32 Size );
58
59 /**
60 * Accesses the data at passed in offset and returns it. The memory is read-only and
61 * memory will be freed in call to unlock. The lifetime of the data is till the next
62 * call to Unlock, Append or Access
63 *
64 * @param Offset Offset to return corresponding data for
65 */
66 void* Access( int32 Offset );
67
68 /**
69 * @return Number of entries appended.
70 */
71 int32 Num() const
72 {
73 return NumEntries;
74 }
75
76 /**
77 * Helper function to return the amount of memory allocated by this buffer
78 *
79 * @return number of bytes allocated by this buffer
80 */
81 SIZE_T GetAllocatedSize() const
82 {
83 return CompressedBuffer.GetAllocatedSize()
84 + PendingCompressionBuffer.GetAllocatedSize()
85 + DecompressedBuffer.GetAllocatedSize()
86 + BookKeepingInfo.GetAllocatedSize();
87 }
88
89private:
90
91 /** Helper structure for book keeping. */
93 {
94 /** Offset into compressed data. */
96 /** Size of compressed data in this chunk. */
98 /** Offset into uncompressed data. */
100 /** Size of uncompressed data in this chunk. */
102 };
103
104 /** Maximum chunk size to compress in uncompressed bytes. */
106 /** Compression format used to compress the data. */
108 /** Compression flags used to compress the data. */
110 /** Current offset in uncompressed data. */
112 /** Number of entries in buffer. */
114 /** Compressed data. */
116 /** Data pending compression once size limit is reached. */
118 /** Temporary decompression buffer used between Lock/ Unlock. */
120 /** Index into book keeping info associated with decompressed buffer. */
122 /** Book keeping information for decompression/ access. */
124};
ECompressionFlags
@ COMPRESS_None
#define UE_DEPRECATED(Version, Message)
void * Access(int32 Offset)
FCompressedGrowableBuffer(int32 MaxPendingBufferSize, ECompressionFlags CompressionFlags)
FCompressedGrowableBuffer(int32 MaxPendingBufferSize, FName COmpressionFormat, ECompressionFlags CompressionFlags=COMPRESS_None)
int32 Append(void *Data, int32 Size)
TArray< FBufferBookKeeping > BookKeepingInfo
FCompressedGrowableBuffer(EVS2015Redirector, int32 MaxPendingBufferSize, ECompressionFlags CompressionFlags)