SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
RWTInputStreamLockImp< InputStream, FilteredInputStreamImp > Class Template Reference

Implements a simple lock stream that can be used with any kind of input stream. More...

#include <rw/stream/RWTInputStreamLockImp.h>

Inherits FilteredInputStreamImp.

Public Types

typedef InputStream::element_type element_type
 
typedef InputStream RWInputStream_type
 

Public Member Functions

virtual ~RWTInputStreamLockImp ()
 
virtual InputStream acquire ()
 
virtual RWSize available () const
 
virtual void close ()
 
virtual bool isBad () const
 
virtual bool isEof () const
 
virtual bool isFail () const
 
virtual bool isGood () const
 
virtual element_type read ()
 
virtual RWSize read (element_type *array, RWSize num)
 
virtual void release ()
 
virtual RWSize skip (RWSize numUnits)
 

Static Public Member Functions

static InputStream make (const InputStream &sourceStream)
 

Protected Member Functions

 RWTInputStreamLockImp (const InputStream &sourceStream)
 
RWMutexLockgetStreamMutex ()
 
RWMutexLockgetStreamMutex () const
 

Detailed Description

template<class InputStream, class FilteredInputStreamImp>
class RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >

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.

Member Typedef Documentation

template<class InputStream, class FilteredInputStreamImp>
typedef InputStream::element_type RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::element_type

A typedef for the type of element to be read from RWInputStream_type.

template<class InputStream, class FilteredInputStreamImp>
typedef InputStream RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::RWInputStream_type

A typedef for the template parameter InputStream which will be used as the source of elements.

Constructor & Destructor Documentation

template<class InputStream, class FilteredInputStreamImp>
virtual RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::~RWTInputStreamLockImp ( )
virtual

Destructor.

template<class InputStream, class FilteredInputStreamImp>
RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::RWTInputStreamLockImp ( const InputStream &  sourceStream)
protected

Initializes the reference to the input stream that will be used as the source of elements.

Parameters
sourceStreamThe input stream that will serve as the source of elements.

Member Function Documentation

template<class InputStream, class FilteredInputStreamImp>
virtual InputStream RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::acquire ( )
virtual

Acquires the stream's internal synchronization mechanism. The acquire() member function returns a handle to the next processing stream.

template<class InputStream, class FilteredInputStreamImp>
virtual RWSize RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::available ( ) const
virtual

Returns the number of elements that can be read from the stream without blocking. Throws no exceptions.

template<class InputStream, class FilteredInputStreamImp>
virtual void RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::close ( )
virtual

Calls close on the next processing stream.

template<class InputStream , class FilteredInputStreamImp >
RWMutexLock & RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::getStreamMutex ( )
inlineprotected

These functions return the stream's internal synchronization mechanism. They throw no exceptions.

template<class InputStream , class FilteredInputStreamImp >
RWMutexLock & RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::getStreamMutex ( ) const
inlineprotected

These functions return the stream's internal synchronization mechanism. They throw no exceptions.

template<class InputStream, class FilteredInputStreamImp>
virtual bool RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::isBad ( ) const
virtual

If the stream is in bad state, then this function returns true, otherwise it returns false. Throws no exceptions.

template<class InputStream, class FilteredInputStreamImp>
virtual bool RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::isEof ( ) const
virtual

If no data can be obtained from the input sequence, this function returns true, otherwise it returns false. Throws no exceptions.

template<class InputStream, class FilteredInputStreamImp>
virtual bool RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::isFail ( ) const
virtual

If the stream is in fail state, then this function returns true, otherwise it returns false. Throws no exceptions.

template<class InputStream, class FilteredInputStreamImp>
virtual bool RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::isGood ( ) const
virtual

If the stream is in fail or bad state, then this function returns false, otherwise it returns true. Throws no exceptions.

template<class InputStream, class FilteredInputStreamImp>
static InputStream RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::make ( const InputStream &  sourceStream)
inlinestatic

Constructs an RWTInputStreamLockImp instance that uses sourceStream as its source of elements, and returns a handle to it. Throws no exceptions.

Parameters
sourceStreamThe output stream that will serve as the source of elements.
template<class InputStream, class FilteredInputStreamImp>
virtual element_type RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::read ( )
virtual

Reads a single element.

template<class InputStream, class FilteredInputStreamImp>
virtual RWSize RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::read ( element_type array,
RWSize  num 
)
virtual

Reads an array of elements. The function returns the actual number of elements read.

Parameters
arrayA pointer to the first element of the array. The array must have been pre-allocated to contain at least num elements.
numThe number of elements to be read from the stream.
template<class InputStream, class FilteredInputStreamImp>
virtual void RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::release ( )
virtual

Releases the stream's internal synchronization mechanism.

template<class InputStream, class FilteredInputStreamImp>
virtual RWSize RWTInputStreamLockImp< InputStream, FilteredInputStreamImp >::skip ( RWSize  numUnits)
virtual

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.

Parameters
numUnitsThe number of elements to be skipped.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.