Public Member Functions | |
this (IReader reader) | |
this (IReader reader, int width) | |
void | get (IReadable target) |
Private Attributes | |
int | width |
IReader | reader |
The approach leverages the exisiting IReadable interface which, when implemented, exposes a class that reads a related set of data. For instance:
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.
|
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. |
|
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(). |
|
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. |
|
Definition at line 97 of file CompositeReader.d. |
|
Definition at line 98 of file CompositeReader.d. |