Re: I/O class: how to design for special case



Simon,

If you ask the CFooBuffer instance to get the data itself, then pass it
to the CFoo::out routine.
The data must be coming from somewhere, so try this:

CFooBuffer::readFrom(Object source)

If the Object is a socket then handle it, if its a file, then handle
that.

This approach means:

1. You ask the CFoo class for the CFooBuffer that best suits it (which
was a requirement) and,
2. You dont expose anything about the internals of CFoo or CFooBuffer
and,
3. You dont have non-required reads/write to the CFooBuffer because its
the thing that does the reading/writing
into its own internal buffer.

I hope this helps. Keep well,

Rgs, James.

.