CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::SyncDataStreamAdapter Class Reference

An adapter stream that turns an DataStream into an AsyncDataStream. More...

#include <CeresEngine/Foundation/IO/Stream.hpp>

Inheritance diagram for CeresEngine::SyncDataStreamAdapter:
CeresEngine::IAsyncDataStream CeresEngine::IAsyncInputStream CeresEngine::IAsyncOutputStream CeresEngine::IAsyncStream CeresEngine::IAsyncStream

Public Member Functions

 SyncDataStreamAdapter (DataStream dataStream, ExecutionContext &executionContext)
 
bool isSeekable (const Seek mode=Seek::Start) const noexcept final
 Checks if the stream is seekable.
 
Async seek (std::streamsize position, Seek mode=Seek::Start) final
 Changes the position of the data stream.
 
bool isTellable () const noexcept final
 Checks if the stream knows the size of the data.
 
Async< size_ttell () final
 Gets the number of bytes available on the stream.
 
bool isSizeKnown () const noexcept final
 Checks if the stream knows the size of the data.
 
Async< size_tsize () final
 Gets the number of bytes available on the stream.
 
bool isReadable () const noexcept final
 Checks if the stream is readable.
 
Async< size_tread (void *data, size_t n) final
 Reads data from the data stream to a buffer of raw memory data with length n.
 
bool isWritable () const noexcept final
 Checks if the stream is writable.
 
Async< size_twrite (const void *data, size_t n) final
 Writes data tp the data stream from a buffer of raw memory data with length n.
 
Async wait () final
 Waits until all pending operations on the stream are complete.
 
- Public Member Functions inherited from CeresEngine::IAsyncInputStream
virtual Async< size_treadExactly (void *data, size_t n)
 Similar to read(void*, size_t), but ensures that the entire data buffer is filled with exactly n bytes or up to the end of the data stream.
 
- Public Member Functions inherited from CeresEngine::IAsyncStream
virtual ~IAsyncStream ()=default
 Default virtual destructor.
 
Async skip (const size_t n)
 Skips n bytes from the data stream.
 
- Public Member Functions inherited from CeresEngine::IAsyncOutputStream
virtual Async< size_twriteExactly (void *data, size_t n)
 Similar to write(const void*, size_t), but ensures that the entire data buffer is written with exactly n bytes or up to the end of the data stream.
 

Private Attributes

DataStream mDataStream
 
ExecutionContextmExecutionContext
 

Additional Inherited Members

- Public Types inherited from CeresEngine::IAsyncStream
using Seek = IStream::Seek
 An enumeration that describes how a data stream should be seeked.
 

Detailed Description

An adapter stream that turns an DataStream into an AsyncDataStream.

Constructor & Destructor Documentation

◆ SyncDataStreamAdapter()

CeresEngine::SyncDataStreamAdapter::SyncDataStreamAdapter ( DataStream  dataStream,
ExecutionContext executionContext 
)
explicit

Member Function Documentation

◆ isReadable()

bool CeresEngine::SyncDataStreamAdapter::isReadable ( ) const
inlinefinalvirtualnoexcept

Checks if the stream is readable.

If this method returns true, read() is safe to be called on this stream.

Reimplemented from CeresEngine::IAsyncInputStream.

◆ isSeekable()

bool CeresEngine::SyncDataStreamAdapter::isSeekable ( const Seek  mode = Seek::Start) const
inlinefinalvirtualnoexcept

Checks if the stream is seekable.

If this method returns true, seek() is safe to be called on this stream.

Reimplemented from CeresEngine::IAsyncStream.

◆ isSizeKnown()

bool CeresEngine::SyncDataStreamAdapter::isSizeKnown ( ) const
inlinefinalvirtualnoexcept

Checks if the stream knows the size of the data.

If this method returns true, size() is safe to be called on this stream.

Reimplemented from CeresEngine::IAsyncStream.

◆ isTellable()

bool CeresEngine::SyncDataStreamAdapter::isTellable ( ) const
inlinefinalvirtualnoexcept

Checks if the stream knows the size of the data.

If this method returns true, tell() is safe to be called on this stream.

Reimplemented from CeresEngine::IAsyncStream.

◆ isWritable()

bool CeresEngine::SyncDataStreamAdapter::isWritable ( ) const
inlinefinalvirtualnoexcept

Checks if the stream is writable.

If this method returns true, write() is safe to be called on this stream.

Reimplemented from CeresEngine::IAsyncOutputStream.

◆ read()

Async< size_t > CeresEngine::SyncDataStreamAdapter::read ( void data,
size_t  n 
)
finalvirtual

Reads data from the data stream to a buffer of raw memory data with length n.

Note
This method is only callable if isReadable() returns true.
Parameters
dataThe memory location to which read data should be placed.
nThe maximum number of bytes to be read from the data stream.
Returns
The number of bytes actually read. Can be smaller than n. If 0, indicates that the stream has ended.

Reimplemented from CeresEngine::IAsyncInputStream.

◆ seek()

Async CeresEngine::SyncDataStreamAdapter::seek ( std::streamsize  position,
Seek  mode = Seek::Start 
)
finalvirtual

Changes the position of the data stream.

Note
This method is only callable if isSeekable() returns true.
Parameters
positionThe position to set the data stream to.
modeThe mode to change the data stream position.

Reimplemented from CeresEngine::IAsyncStream.

◆ size()

Async< size_t > CeresEngine::SyncDataStreamAdapter::size ( )
finalvirtual

Gets the number of bytes available on the stream.

Note
This method is only callable if isSizeKnown() returns true.

Reimplemented from CeresEngine::IAsyncStream.

◆ tell()

Async< size_t > CeresEngine::SyncDataStreamAdapter::tell ( )
finalvirtual

Gets the number of bytes available on the stream.

Note
This method is only callable if isTellable() returns true.

Reimplemented from CeresEngine::IAsyncStream.

◆ wait()

Async CeresEngine::SyncDataStreamAdapter::wait ( )
finalvirtual

Waits until all pending operations on the stream are complete.

Returns
A continuable that terminates once all operations on the data stream are complete.

Implements CeresEngine::IAsyncStream.

◆ write()

Async< size_t > CeresEngine::SyncDataStreamAdapter::write ( const void data,
size_t  n 
)
finalvirtual

Writes data tp the data stream from a buffer of raw memory data with length n.

Note
This method is only callable if isWritable() returns true.
Parameters
dataThe memory location to which written data should be copied from.
nThe maximum number of bytes to be write to the data stream.
Returns
The number of bytes actually written. Can be smaller than n, in that case the write operation must be repeated to ensure that all data was written. If 0, indicates that the stream has ended.

Reimplemented from CeresEngine::IAsyncOutputStream.

Member Data Documentation

◆ mDataStream

DataStream CeresEngine::SyncDataStreamAdapter::mDataStream
private

◆ mExecutionContext

ExecutionContext& CeresEngine::SyncDataStreamAdapter::mExecutionContext
private

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