IReadStream

Class Hierarchy
C++
class IReadStream;
File

IStreamEngine.h

Description

This is the file "handle" that can be used to query the status of the asynchronous operation on the file. The same object may be returned for the same file to multiple clients. Notes: It will actually represent the asynchronous object in memory, and will be thread-safe reference-counted (both AddRef() and Release() will be virtual and thread-safe, just like the others)

Example

USE: IReadStream_AutoPtr pReadStream = pStreamEngine->StartRead ("bla.xxx", this); OR: pStreamEngine->StartRead ("MusicSystem","bla.xxx", this);

IReadStream::~IReadStream Destructor

The clients are not allowed to destroy this object directly; only via Release().

C++
virtual ~IReadStream();
IReadStream::Abort Method
C++
virtual void Abort() = 0;
Description

Tries to stop reading the stream; this is advisory and may have no effect but the callback will not be called after this. If you just destructing object, dereference this object and it will automatically abort and release all associated resources.

IReadStream::AddRef Method

Increment ref count, returns new count

C++
virtual int AddRef() = 0;
IReadStream::FreeTemporaryMemory Method

Free temporary memory allocated for this stream, when not needed anymore. Can be called from Async callback, to free memory earlier, not waiting for synchrounus callback.

C++
virtual void FreeTemporaryMemory() = 0;
IReadStream::GetBuffer Method
C++
virtual const void* GetBuffer() = 0;
Description

Returns the buffer into which the data has been or will be read at least GetBytesRead() bytes in this buffer are guaranteed to be already read. Notes: DO NOT USE THIS BUFFER during read operation! DO NOT READ from it, it can lead to memory corruption!

IReadStream::GetBytesRead Method
C++
virtual unsigned int GetBytesRead(bool bWait = false) = 0;
Parameters
Parameters
Description
bool bWait = false
if == true, then waits until the pending I/O operation completes.
Returns

The total number of bytes read (if it completes successfully, returns the size of block being read)

Description

Returns the number of bytes read so far (the whole buffer size if IsFinished())

IReadStream::GetCallback Method

Returns pointer to callback routine(can be NULL).

C++
virtual IStreamCallback* GetCallback() const = 0;
IReadStream::GetCallerType Method

Returns caller type.

C++
virtual const EStreamTaskType GetCallerType() const = 0;
IReadStream::GetError Method

Returns IO error #.

C++
virtual unsigned GetError() const = 0;
IReadStream::GetErrorName Method

Returns IO error name

C++
virtual const char* GetErrorName() const = 0;
IReadStream::GetMediaType Method

Returns media type used to satisfy request - only valid once stream has begun read.

C++
virtual EStreamSourceMediaType GetMediaType() const = 0;
IReadStream::GetName Method

Returns stream name.

C++
virtual const char* GetName() const = 0;
IReadStream::GetParams Method

Returns stream params.

C++
virtual const StreamReadParams& GetParams() const = 0;
IReadStream::GetUserData Method
C++
virtual DWORD_PTR GetUserData() = 0;
Description

Returns the transparent DWORD that was passed in the StreamReadParams::dwUserData field of the structure passed in the call to IStreamEngine::StartRead.

See Also
IReadStream::IsError Method

Returns true if the file read was not successful.

C++
virtual bool IsError() = 0;
IReadStream::IsFinished Method

Checks IsError to check if the whole requested file (piece) was read.

C++
virtual bool IsFinished() = 0;
Returns

True if the file read was completed successfully.

IReadStream::Release Method

Decrement ref count, returns new count

C++
virtual int Release() = 0;
IReadStream::SetUserData Method

Set user defined data into stream's params.

C++
virtual void SetUserData(DWORD_PTR dwUserData) = 0;
IReadStream::TryAbort Method
C++
virtual bool TryAbort() = 0;
Description

Tries to stop reading the stream, as long as IO or the async callback is not currently in progress.

IReadStream::Wait Method

Unconditionally waits until the callback is called. if nMaxWaitMillis is not negative wait for the specified ammount of milliseconds then exit.

C++
virtual void Wait(int nMaxWaitMillis = -1) = 0;
Example

If the stream hasn't yet finish, it's guaranteed that the user-supplied callback is called before return from this function (unless no callback was specified).