next up previous contents
Next: Basic Instantiation Up: Streams and Iterators Previous: Basic Protocol   Contents

Basic Stream Variants

Figure 2 shows the major stream types and their relationships.

Figure 2: Stream Inheritance

Stream
provides the basic protocol for instantiating streams.
ReadStream
provides the basic protocol for input access from a source.
WriteStream
provides the basic protocol for output access to a target.
ReadWriteStream
provides the basic protocol for both read and write access, and caches its input as necessary.
PeekableStream
extends Stream to provide the ability to look forward on the stream without advancing it.
PositionableStream
extends PeekableStream to provide a basic protocol to iterate over a sequence of elements from a Sequence or a file or other source. These streams store their position in the sequence as they iterate, and are re-positionable. It also has its own variants, -Read-, -Write-, and -ReadWrite-.
DummyStream
is a (singleton) ReadWriteStream that just answers Nil repeatedly (and does nothing on writing). It is best created by applying the reader, writer, or iterator methods to Nil.
EchoStream
is a wrapper for a Stream which copies all stream input/output interactions to another Stream for logging purposes. It is best created by applying the echo (goes to the Console) or echoTo: anotherStream methods to any stream. It answers the original stream, so that further processing can be chained.
Method ReadStream
is a ReadStream that targets a no-input block and returns its output each time. It is best created by applying the reader or iterator method to any block.
Method WriteStream
is a WriteStream that targets a single-input block and applies its input each time. It is best created by applying the writer method to any block.
StreamProcessor
is an abstract kind of ReadStream that has a source ReadStream which it processes in some way. Derivatives specialize it in various useful ways.
FilterStream
is a StreamProcessor that returns the elements of a wrapped ReadStream that satisfy the logical test of a single-argument block being applied to each element. It is created by applying the select: or reject: method to any Stream.
CollectStream
is a StreamProcessor that returns the results of applying a single-argument block to each element of a ReadStream that it wraps. It is created by applying the collect: method to any Stream.
BufferReadStream
wraps another stream with a special Buffer object for reading large chunks from the stream at a time while handing out the elements as requested. This also minimizes stress on the memory-allocator by avoiding unnecessary allocation of arrays. It is created by applying the readBuffered method to any Stream.
BufferWriteStream
wraps another stream with a special Buffer object for writing large chunks to the stream at a time while accepting new elements as requested. This also minimizes stress on the memory-allocator by avoiding unnecessary allocation of arrays. It is created by applying the writeBuffered method to any Stream.


next up previous contents
Next: Basic Instantiation Up: Streams and Iterators Previous: Basic Protocol   Contents
Brian Rice 2004-08-24