SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 (void)
 
virtual RWSize available (void) const
 
virtual void close (void)
 
virtual bool isBad (void) const
 
virtual bool isEof (void) const
 
virtual bool isFail (void) const
 
virtual bool isGood (void) const
 
virtual RWSize read (element_type *array, RWSize num)
 
virtual element_type read (void)
 
virtual void release (void)
 
virtual RWSize skip (RWSize numUnits)
 

Static Public Member Functions

static InputStream make (const InputStream &sourceStream)
 

Protected Member Functions

 RWTInputStreamLockImp (const InputStream &sourceStream)
 
RWMutexLockgetStreamMutex (void)
 
RWMutexLockgetStreamMutex (void) 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

◆ element_type

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.

◆ 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

◆ ~RWTInputStreamLockImp()

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

Destructor.

◆ RWTInputStreamLockImp()

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

◆ acquire()

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

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

◆ available()

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

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

◆ close()

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

Calls close on the next processing stream.

◆ getStreamMutex() [1/2]

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

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

◆ getStreamMutex() [2/2]

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

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

◆ isBad()

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

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

◆ isEof()

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

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

◆ isFail()

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

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

◆ isGood()

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

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

◆ make()

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.

◆ read() [1/2]

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.

◆ read() [2/2]

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

Reads a single element.

◆ release()

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

Releases the stream's internal synchronization mechanism.

◆ skip()

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 © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.