Plasma Engine  2.0
Loading...
Searching...
No Matches
plDefaultMemoryStreamStorage Class Referencefinal

The default implementation for memory stream storage. More...

#include <MemoryStream.h>

Inheritance diagram for plDefaultMemoryStreamStorage:

Public Member Functions

 plDefaultMemoryStreamStorage (plUInt32 uiInitialCapacity=0, plAllocator *pAllocator=plFoundation::GetDefaultAllocator())
 
virtual void Reserve (plUInt64 uiBytes) override
 Reserves N bytes of storage.
 
virtual plUInt64 GetStorageSize64 () const override
 Returns the number of bytes that are currently stored.
 
virtual void Clear () override
 Clears the entire storage. All readers and writers must be reset to start from the beginning again.
 
virtual void Compact () override
 Deallocates any allocated memory that's not needed to hold the currently stored data.
 
virtual plUInt64 GetHeapMemoryUsage () const override
 Returns the amount of bytes that are currently allocated on the heap.
 
virtual plResult CopyToStream (plStreamWriter &inout_stream) const override
 Writes the entire content of the storage to the provided stream.
 
virtual plArrayPtr< const plUInt8 > GetContiguousMemoryRange (plUInt64 uiStartByte) const override
 Returns a read-only plArrayPtr that represents a contiguous area in memory which starts at the given first byte.
 
virtual plArrayPtr< plUInt8 > GetContiguousMemoryRange (plUInt64 uiStartByte) override
 Non-const overload of GetContiguousMemoryRange().
 
- Public Member Functions inherited from plMemoryStreamStorageInterface
plUInt32 GetStorageSize32 () const
 Returns the number of bytes that are currently stored. Asserts that the stored amount is less than 4GB.
 
void ReadAll (plStreamReader &inout_stream, plUInt64 uiMaxBytes=plMath::MaxValue< plUInt64 >())
 Copies all data from the given stream into the storage.
 

Detailed Description

The default implementation for memory stream storage.

This implementation of plMemoryStreamStorageInterface handles use cases both from very small to extremely large storage needs. It starts out with some inplace memory that can accommodate small amounts of data. To grow, additional chunks of data are allocated. No memory ever needs to be copied to grow the container. However, that also means that the memory isn't stored in one contiguous array, therefore data has to be accessed piece-wise through GetContiguousMemoryRange().

Member Function Documentation

◆ Clear()

void plDefaultMemoryStreamStorage::Clear ( )
overridevirtual

Clears the entire storage. All readers and writers must be reset to start from the beginning again.

Implements plMemoryStreamStorageInterface.

◆ Compact()

void plDefaultMemoryStreamStorage::Compact ( )
overridevirtual

Deallocates any allocated memory that's not needed to hold the currently stored data.

Implements plMemoryStreamStorageInterface.

◆ CopyToStream()

plResult plDefaultMemoryStreamStorage::CopyToStream ( plStreamWriter & inout_stream) const
overridevirtual

Writes the entire content of the storage to the provided stream.

Implements plMemoryStreamStorageInterface.

◆ GetContiguousMemoryRange() [1/2]

plArrayPtr< const plUInt8 > plDefaultMemoryStreamStorage::GetContiguousMemoryRange ( plUInt64 uiStartByte) const
overridevirtual

Returns a read-only plArrayPtr that represents a contiguous area in memory which starts at the given first byte.

This piece of memory can be read/copied/modified in one operation (memcpy etc). The next byte after this slice may be located somewhere entirely different in memory. Call GetContiguousMemoryRange() again with the next byte after this range, to get access to the next memory area.

Chunks may differ in size.

Implements plMemoryStreamStorageInterface.

◆ GetContiguousMemoryRange() [2/2]

plArrayPtr< plUInt8 > plDefaultMemoryStreamStorage::GetContiguousMemoryRange ( plUInt64 uiStartByte)
overridevirtual

Non-const overload of GetContiguousMemoryRange().

Implements plMemoryStreamStorageInterface.

◆ GetHeapMemoryUsage()

plUInt64 plDefaultMemoryStreamStorage::GetHeapMemoryUsage ( ) const
overridevirtual

Returns the amount of bytes that are currently allocated on the heap.

Implements plMemoryStreamStorageInterface.

◆ GetStorageSize64()

plUInt64 plDefaultMemoryStreamStorage::GetStorageSize64 ( ) const
overridevirtual

Returns the number of bytes that are currently stored.

Implements plMemoryStreamStorageInterface.

◆ Reserve()

void plDefaultMemoryStreamStorage::Reserve ( plUInt64 uiBytes)
overridevirtual

Reserves N bytes of storage.

Implements plMemoryStreamStorageInterface.

◆ SetInternalSize()

void plDefaultMemoryStreamStorage::SetInternalSize ( plUInt64 uiSize)
overrideprivatevirtual

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