Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
MemoryReadStream.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 "HAL/Platform.h"
7#include "HAL/ThreadSafeCounter.h"
8#include "Templates/RefCounting.h"
9
10/**
11 * Represents a block of memory, but abstracts away the underlying layout
12 */
14{
15public:
16 static TRefCountPtr<IMemoryReadStream> CreateFromCopy(const void* InMemory, int64 InSize);
18 static TRefCountPtr<IMemoryReadStream> CreateFromBuffer(void* InMemory, int64 InSize, bool bOwnPointer);
19
20 virtual const void* Read(int64& OutSize, int64 InOffset, int64 InSize) = 0;
21 virtual int64 GetSize() = 0;
22 virtual void CopyTo(void* Buffer, int64 InOffset, int64 InSize);
23 virtual void EnsureReadNonBlocking() {}; // Incur any potential wait such that future Read() or CopyTo() calls are wait and thread switch free.
24
25 FORCEINLINE uint32 AddRef() const { return uint32(NumRefs.Increment()); }
26
27 FORCEINLINE uint32 Release() const
28 {
29 const int32 Refs = NumRefs.Decrement();
30 if (Refs == 0)
31 {
32 delete this;
33 }
34 return uint32(Refs);
35 }
36
37 FORCEINLINE uint32 GetRefCount() const
38 {
39 return uint32(NumRefs.GetValue());
40 }
41
42protected:
43 virtual ~IMemoryReadStream() {}
44
45private:
47};
TRefCountPtr< IMemoryReadStream > IMemoryReadStreamRef
#define FORCEINLINE
Definition Platform.h:644
FORCEINLINE uint32 GetRefCount() const
static TRefCountPtr< IMemoryReadStream > CreateFromBuffer(void *InMemory, int64 InSize, bool bOwnPointer)
virtual void EnsureReadNonBlocking()
static TRefCountPtr< IMemoryReadStream > CreateFromCopy(const void *InMemory, int64 InSize)
static TRefCountPtr< IMemoryReadStream > CreateFromCopy(IMemoryReadStream *InStream)
virtual ~IMemoryReadStream()
FORCEINLINE uint32 AddRef() const
virtual int64 GetSize()=0
FORCEINLINE uint32 Release() const
virtual void CopyTo(void *Buffer, int64 InOffset, int64 InSize)
FThreadSafeCounter NumRefs
virtual const void * Read(int64 &OutSize, int64 InOffset, int64 InSize)=0