University of Sheffield   

    The Simons
    Component Library

Introduction   Class Hierarchy   Class Listing   Index of Classes   Index of Methods   Header Files  

Stream Class Reference

#include <Stream.h>

Inheritance diagram for Stream:

Object FileStream FormatStream Input Output Reader Writer TextInput TextOutput CGIReader XMLReader XMLWriter WebOutput List of all members.

Detailed Description

Stream: the abstract superclass of all data streams and pipes.

The Stream class is the root of the streams hierarchy, which includes the FileStream classes, which connect to the underlying filesystem and perform basic read and write operations, and the FormatStream classes, which wrap around the FileStream classes and provide data encoding and decoding in different formats. Further PipeStream subclasses may act as data connections between objects that produce or consume data. A Stream must always be explicitly opened before it is used; and it may be closed after use (otherwise, it will be closed automatically when it is no longer reachable). Stream provides a protocol to test the state of the Stream, which is implemented in descendant classes.


Public Member Functions

 Stream ()
 Construct an empty Stream.

virtual ~Stream ()
 Release a Stream.

virtual Void openOn (StringID)
 Open this Stream on a pathname.

virtual Void open ()
 Open this Stream.

virtual Void close ()
 Close this Stream.

virtual StringID name () const
 Return the name of this Stream.

virtual Boolean exists () const
 Test if this Stream exists.

virtual Boolean empty () const
 Test if this Stream is empty.

virtual Boolean ready () const
 Test if this Stream is ready.

virtual Boolean failed () const
 Test if this Stream has failed.

virtual Boolean source () const
 Test if this Stream is a source.

virtual Boolean sink () const
 Test if this Stream is a sink.


Protected Member Functions

Void readFailure (StringID, ObjectID) const
 Report that a read-operation failed.

Void writeFailure (StringID, ObjectID) const
 Report that a write-operation failed.

 Stream (const Stream &)
 Copy another Stream.


Constructor & Destructor Documentation

Stream::Stream const Stream &  stream  )  [protected]
 

Copy another Stream.

This method is trivial, since Stream is abstract and has no attributes. Required by C++ to ensure that copying a Stream faithfully copies an Object.

Parameters:
stream - the Stream to copy.
Returns:
the copied Stream.

Stream::Stream  ) 
 

Construct an empty Stream.

Returns:
an empty Stream.

Stream::~Stream  )  [virtual]
 

Release a Stream.

Perform all closing actions upon the Stream before releasing it.


Member Function Documentation

Void Stream::close  )  [virtual]
 

Close this Stream.

Disconnect this Stream from its underlying source or sink. This method is abstract.

Reimplemented in FormatStream, Input, Output, and WebOutput.

Boolean Stream::empty  )  const [virtual]
 

Test if this Stream is empty.

Use this method to discover when there is no more data to read from this Stream. Streams to which data is being written are never empty.

Returns:
true if this Stream is empty, otherwise false.

Reimplemented in FormatStream, and Input.

Boolean Stream::exists  )  const [virtual]
 

Test if this Stream exists.

Use this method to test if the connection with the underlying file system was successfully opened.

Returns:
true if this Stream's connection exists, otherwise false.

Reimplemented in FormatStream, Input, and Output.

Boolean Stream::failed  )  const [virtual]
 

Test if this Stream has failed.

Use this method to test if the Stream failed to complete the previous input or output operation.

Returns:
true if this Stream has failed, otherwise false.

Reimplemented in FormatStream, Input, and Output.

StringID Stream::name  )  const [virtual]
 

Return the name of this Stream.

The result depends on what kind of Stream this is. A FormatStream will return the name of the underlying FileStream that it encapsulates. A FileStream will return the file path name that was supplied, or if no path name was supplied, one of the standard stream names "Standard Input", "Standard Output" or "Standard Error". This method is abstract.

Returns:
the name of this Stream.

Reimplemented in FileStream, and FormatStream.

Void Stream::open  )  [virtual]
 

Open this Stream.

Reconnect this Stream with its underlying source or sink, using the existing pathname. This method is abstract.

Reimplemented in FormatStream, Input, Output, and WebOutput.

Void Stream::openOn StringID  path  )  [virtual]
 

Open this Stream on a pathname.

Connect this Stream with a new source or sink, named by the supplied pathname. This method is abstract.

Parameters:
path - the String pathname.

Reimplemented in CGIReader, FileStream, FormatStream, and WebOutput.

Void Stream::readFailure StringID  method,
ObjectID  datum
const [protected]
 

Report that a read-operation failed.

Provided for convenience, this method is inherited by all streams and may be used to raise a ReadFailure exception to signal that the Stream failed while attempting to read a datum into a variable of a given Type. If the ReadFailure has some prior cause, a second exception is chained to this one.

Parameters:
method - the read-method that failed.
datum - the datum that was being read (possibly blank).

Boolean Stream::ready  )  const [virtual]
 

Test if this Stream is ready.

Use this method to test if the Stream is ready for the next input or output operation.

Returns:
true if this Stream is ready, otherwise false.

Reimplemented in FormatStream, Input, and Output.

Boolean Stream::sink  )  const [virtual]
 

Test if this Stream is a sink.

Use this method to test if the Stream was opened for output, as a sink for the data.

Returns:
true if this Stream is a sink, otherwise false.

Reimplemented in FormatStream, and Output.

Boolean Stream::source  )  const [virtual]
 

Test if this Stream is a source.

Use this method to test if the Stream was opened for input, as a source of data.

Returns:
true if this Stream is a source, otherwise false.

Reimplemented in FormatStream, and Input.

Void Stream::writeFailure StringID  method,
ObjectID  datum
const [protected]
 

Report that a write-operation failed.

Provided for convenience, this method is inherited by all streams and may be used to raise a WriteFailure exception to signal that the Stream failed while attempting to write a datum from a variable of a given Type. If the WriteFailure has some prior cause, a second exception is chained to this one.

Parameters:
method - the write-method that failed.
datum - the datum that was being written.


The documentation for this class was generated from the following files:
Generated on Fri May 5 17:17:19 2006 for The Simons Component Library by doxygen1.3