SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions
RWTStreamGuardImp< StreamHandle, FilteredStreamImp > Class Template Reference

A simple guard stream that can be used with any kind of input/output stream. More...

#include <rw/stream/RWTStreamGuardImp.h>

Inherits FilteredStreamImp.

Public Member Functions

virtual ~RWTStreamGuardImp ()
 

Static Public Member Functions

static StreamHandle make (StreamHandle &stream)
 

Protected Member Functions

 RWTStreamGuardImp (StreamHandle &stream)
 
StreamHandle & getNextStream ()
 
const StreamHandle & getNextStream () const
 

Detailed Description

template<class StreamHandle, class FilteredStreamImp>
class RWTStreamGuardImp< StreamHandle, FilteredStreamImp >

The class RWTStreamGuardImp implements a simple guard stream that can be used with any kind of input/output stream. The stream guard acquires the synchronization mechanism provided by its source/sink stream at construction time, and releases it upon destruction. The guard stream doesn't maintain its own synchronization mechanism, but rather uses the one provided by the next processing stream. If the next processing stream doesn't implement any synchronization mechanism, then the stream guard class has no effect. The guard class is generally used in combination with one of the synchronization classes RWSynchronizedByteInputStreamImp, RWSynchronizedByteOutputStreamImp, RWSynchronizedCharInputStreamImp, RWSynchronizedCharOutputStreamImp, RWSynchronizedDataInputStreamImp, RWSynchronizedDataOutputStreamImp, RWSynchronizedUCharInputStreamImp, RWSynchronizedUCharOutputStreamImp, RWSynchronizedWCharInputStreamImp, or RWSynchronizedWCharOutputStreamImp.

Constructor & Destructor Documentation

template<class StreamHandle , class FilteredStreamImp >
virtual RWTStreamGuardImp< StreamHandle, FilteredStreamImp >::~RWTStreamGuardImp ( )
virtual

Destructor. Releases the lock acquired in the guard stream constructor. If the next processing stream doesn't provide a synchronization mechanism, then the destructor has no effect. Throws no exceptions.

template<class StreamHandle , class FilteredStreamImp >
RWTStreamGuardImp< StreamHandle, FilteredStreamImp >::RWTStreamGuardImp ( StreamHandle &  stream)
protected

Initializes the reference to the stream that will be used as source/sink of elements. Acquires the synchronization mechanism provided by stream if any.

Parameters
streamThe stream that will serve as the source/sink of elements.

Member Function Documentation

template<class StreamHandle , class FilteredStreamImp >
StreamHandle & RWTStreamGuardImp< StreamHandle, FilteredStreamImp >::getNextStream ( )
inlineprotected

Returns a handle to the next processing stream. Throw no exceptions.

template<class StreamHandle , class FilteredStreamImp >
const StreamHandle & RWTStreamGuardImp< StreamHandle, FilteredStreamImp >::getNextStream ( ) const
inlineprotected

Returns a handle to the next processing stream. Throw no exceptions.

template<class StreamHandle , class FilteredStreamImp >
static StreamHandle RWTStreamGuardImp< StreamHandle, FilteredStreamImp >::make ( StreamHandle &  stream)
inlinestatic

Constructs an RWTStreamGuardImp instance that uses stream as its source/sink of elements, and returns a handle to it. Throws no exceptions.

Parameters
streamThe stream that will serve as the source/sink of elements.

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