UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FBufferOwner Class Referenceabstract

#include <SharedBuffer.h>

+ Inheritance diagram for FBufferOwner:

Public Types

enum class  EBufferOwnerFlags : uint8 { None = 0 , Owned = 1 << 0 , Immutable = 1 << 1 , Materialized = 1 << 2 }
 

Protected Member Functions

 FBufferOwner ()=default
 
 FBufferOwner (const FBufferOwner &)=delete
 
FBufferOwneroperator= (const FBufferOwner &)=delete
 
 FBufferOwner (void *InData, uint64 InSize)
 
virtual ~FBufferOwner ()
 
virtual void MaterializeBuffer ()
 
virtual void FreeBuffer ()=0
 
voidGetData ()
 
uint64 GetSize ()
 
void SetBuffer (void *InData, uint64 InSize)
 
bool IsOwned () const
 
void SetIsOwned ()
 
bool IsImmutable () const
 
void SetIsImmutable ()
 
void Materialize ()
 
bool IsMaterialized () const
 
void SetIsMaterialized ()
 
uint32 GetTotalRefCount () const
 

Friends

class FUniqueBuffer
 
class FSharedBuffer
 
class FWeakSharedBuffer
 
struct UE::SharedBuffer::Private::FSharedOps
 
struct UE::SharedBuffer::Private::FWeakOps
 

Detailed Description

A reference-counted owner for a buffer, which is a raw pointer and size.

A buffer owner may own its memory or provide a view into memory owned externally. When used as a non-owning view, the viewed memory must be guaranteed to outlive the buffer owner. When this lifetime guarantee cannot be satisfied, MakeOwned may be called on the reference to the buffer to clone into a new buffer owner that owns the memory.

A buffer owner must be referenced and accessed through one of its three reference types: FUniqueBuffer, FSharedBuffer, or FWeakSharedBuffer.

FUniqueBuffer and FSharedBuffer offer static functions to create a buffer using private buffer owner types that are ideal for most use cases. The TakeOwnership function allows creation of a buffer with a custom delete function. Advanced use cases require deriving from FBufferOwner to enable storage of arbitrary members alongside the data and size, and to enable materialization of the buffer to be deferred.

A derived type must call SetIsOwned from its constructor if they own (or will own) the buffer. A derived type must call SetIsImmutable from its constructor if they want the buffer to become permanently immutable after it is stored in FSharedBuffer, forcing MoveToUnique() to clone it. A derived type must call SetIsMaterialized from its constructor, unless it implements deferred materialization by overriding MaterializeBuffer.

Member Enumeration Documentation

◆ EBufferOwnerFlags

Enumerator
None 
Owned 
Immutable 
Materialized 

Constructor & Destructor Documentation

◆ FBufferOwner() [1/3]

FBufferOwner::FBufferOwner ( )
protecteddefault

◆ FBufferOwner() [2/3]

FBufferOwner::FBufferOwner ( const FBufferOwner )
protecteddelete

◆ FBufferOwner() [3/3]

FBufferOwner::FBufferOwner ( void InData,
uint64  InSize 
)
inlineprotected

◆ ~FBufferOwner()

FBufferOwner::~FBufferOwner ( )
inlineprotectedvirtual

Member Function Documentation

◆ FreeBuffer()

virtual void FBufferOwner::FreeBuffer ( )
protectedpure virtual

Free the buffer and any associated resources.

This is called when the last shared reference is released. The destructor will be called when the last weak reference is released. A buffer owner will always call this function before the calling the destructor, unless an exception was thrown by the constructor.

Implemented in UE::SharedBuffer::Private::FBufferOwnerHeap, UE::SharedBuffer::Private::FBufferOwnerView, and UE::SharedBuffer::Private::FBufferOwnerOuterView.

◆ GetData()

void * FBufferOwner::GetData ( )
inlineprotected

◆ GetSize()

uint64 FBufferOwner::GetSize ( )
inlineprotected

◆ GetTotalRefCount()

uint32 FBufferOwner::GetTotalRefCount ( ) const
inlineprotected

◆ IsImmutable()

bool FBufferOwner::IsImmutable ( ) const
inlineprotected

◆ IsMaterialized()

bool FBufferOwner::IsMaterialized ( ) const
inlineprotected

◆ IsOwned()

bool FBufferOwner::IsOwned ( ) const
inlineprotected

◆ Materialize()

void FBufferOwner::Materialize ( )
inlineprotected

◆ MaterializeBuffer()

void FBufferOwner::MaterializeBuffer ( )
inlineprotectedvirtual

Materialize the buffer by making it ready to be accessed.

This will be called before any access to the data or size, unless SetIsMaterialized is called by the constructor. Accesses from multiple threads will cause multiple calls to this function until at least one has finished.

◆ operator=()

FBufferOwner & FBufferOwner::operator= ( const FBufferOwner )
protecteddelete

◆ SetBuffer()

void FBufferOwner::SetBuffer ( void InData,
uint64  InSize 
)
inlineprotected

◆ SetIsImmutable()

void FBufferOwner::SetIsImmutable ( )
inlineprotected

◆ SetIsMaterialized()

void FBufferOwner::SetIsMaterialized ( )
inlineprotected

◆ SetIsOwned()

void FBufferOwner::SetIsOwned ( )
inlineprotected

Friends And Related Symbol Documentation

◆ FSharedBuffer

friend class FSharedBuffer
friend

◆ FUniqueBuffer

friend class FUniqueBuffer
friend

◆ FWeakSharedBuffer

friend class FWeakSharedBuffer
friend

◆ UE::SharedBuffer::Private::FSharedOps

friend struct UE::SharedBuffer::Private::FSharedOps
friend

◆ UE::SharedBuffer::Private::FWeakOps

friend struct UE::SharedBuffer::Private::FWeakOps
friend

The documentation for this class was generated from the following file: