Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

CompositeReader Class Reference

List of all members.

Public Member Functions

 this (IReader reader)
 this (IReader reader, int width)
void get (IReadable target)

Private Attributes

int width
IReader reader

Detailed Description

CompositeReader 'brackets' the reading of a data set.

The approach leverages the exisiting IReadable interface which, when implemented, exposes a class that reads a related set of data. For instance:

class Foo : IReadable { int x, y; char[] text; void read (IReader reader) { reader.get(x).get(y).get(text); } }

In the above example, we set up a class that implements IReadable via the read() method. The class may read whatever it chooses, and may also invoke the read() method of other IReadable classes. Thus, the initial IReadable has control over a potential readable cluster, all of which is bracketed within the CompositeReader.

This CompositeReader ensure it has enough space in the buffer to read an entire data-set, such that buffer slices mapped into user space will all be valid. This does not apply where mapping is not enabled (which is the default setting for all readers).

A word on buffer-mapping: There are a number of situations where a programmer prefers to avoid the overhead of memory allocation & subsequent copying of data. Other times, the liveness of content is more important. The former is attractive in high-performance systems, whereas the latter is typical of most casual IO.

Most programs won't reap any benefit from buffer-mapping, but may run afoul of liveness concerns. Therefore, mapping is disabled on all readers by default. That is, all array types are allocated & copied as they are read. Change this via Reader.setMapped().

Note that buffer-mapping applies only to array[] data types. All integral types are copied directly into local program space.

See CompositeWriter for additional examples.

Definition at line 95 of file CompositeReader.d.


Member Function Documentation

this IReader  reader  )  [inline]
 

Construct a composite with the given reader. The reader should be configured for non-mapped input (the default state for Readers).

Definition at line 108 of file CompositeReader.d.

this IReader  reader,
int  width
[inline]
 

Construct a composite with the given reader, and the maximum width of an input data-set. The width is used to ensure that an entire data-set will be present in the buffer at one time. The reader is configured for mapped input.

Use the other constructor(s) for non-mapped input.

Definition at line 126 of file CompositeReader.d.

References IReader::getBuffer(), and IBuffer::getCapacity().

void get IReadable  target  )  [inline]
 

Read a data-set, after ensuring there's enough buffer space for mapping the entire content (where necessary).

Definition at line 144 of file CompositeReader.d.


Member Data Documentation

int width [private]
 

Definition at line 97 of file CompositeReader.d.

IReader reader [private]
 

Definition at line 98 of file CompositeReader.d.


The documentation for this class was generated from the following file:
Generated on Sun Oct 24 22:31:22 2004 for Mango by doxygen 1.3.6