Module: Advanced Tools Package: Streams
RWTInputStreamLockImp FilteredInputStreamImp
acquire() available() close() element_type |
getStreamMutex() isBad() isEof() isFail() |
isGood() make() read() release() |
RWInputStream_type RWTInputStreamLockImp() skip() ~RWTInputStreamLockImp() |
#include <rw/stream/RWTInputStreamLockImp.h>
The class RWTInputStreamLockImp implements a simple lock stream that can be used with any kind of input stream. The stream locks its internal synchronization mechanism, before forwarding input requests to its associated source stream, and then unlocks the internal synchronization mechanism upon completion. The stream's internal synchronization mechanism is locked using a guard object, ensuring its proper release in the event that an exception is thrown.
typedef InputStream RWInputStream_type RWInputStream_type typedef typename InputStream::element_type element_type
RWTInputStreamLockImp(InputStream& sourceStream);
Initializes the reference to the input stream that will be used as the source of elements.
Parameter List
sourceStream |
The input stream that will serve as the source of elements. |
virtual ~RWTInputStreamLockImp();
Destructor.
static InputStream make(InputStream& sourceStream);
Constructs an RWTInputStreamLockImp instance that uses sourceStream as its source of elements, and returns a handle to it. Throws no exceptions.
Parameter List
sourceStream |
The output stream that will serve as the source of elements. |
virtual InputStream acquire();
Acquires the stream's internal synchronization mechanism. The acquire() member function returns a handle to the next processing stream.
virtual RWSize available() const;
Returns the number of elements that can be read from the stream without blocking. Throws no exceptions.
virtual void close();
Calls close on the next processing stream.
virtual bool isBad() const;
If the stream is in bad state, then this function returns true, otherwise it returns false. Throws no exceptions.
virtual bool isEof() const;
If no data can be obtained from the input sequence, this function returns true, otherwise it returns false. Throws no exceptions.
virtual bool isFail() const;
If the stream is in fail state, then this function returns true, otherwise it returns false. Throws no exceptions.
virtual bool isGood() const;
If the stream is in fail or bad state, then this function returns false, otherwise it returns true. Throws no exceptions.
virtual element_type read();
Reads a single element.
virtual RWSize read(element_type* array, RWSize num);
Reads an array of elements. The function returns the actual number of elements read.
Parameter List
array |
A pointer to the first element of the array. The array must have been pre-allocated to contain at least num elements. |
num |
The number of elements to be read from the stream. |
virtual void release();
Releases the stream's internal synchronization mechanism.
virtual RWSize skip(RWSize numUnits);
Skips numUnits elements from the input sequence if possible. The function returns the actual number of elements skipped, which can be any value between 0 and numUnits.
Parameter List
numUnits |
The number of elements to be skipped. |
RWMutexLock& getStreamMutex() const; RWMutexLock& getStreamMutex();
These functions return the stream's internal synchronization mechanism. They throw no exceptions.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.