Inheritance diagram for IConduitSink:
Public Member Functions | |
int | writer (void[] src) |
void | bind (IConduitSink next) |
void | unbind () |
Filters are chained together such that the last filter added is the first one invoked. It is the responsibility of each filter to invoke the next link in the chain; for example:
class MungingOutputFilter : FilterOutput { int writer (void[] src) { char[src.length] tmp; // set everything to '*' tmp = '*'; // write the munged output return next.writer (tmp); } }
Notice how the filter invokes the 'next' instance after munging the content ... the far end of the chain is where the original IConduit writer is attached, so it will get invoked eventually assuming each filter invokes 'next'. If the next writer fails it will return IConduit.Eof, as should your filter (or throw an IOException). At the client level, filters are attached like this:
FileConduit fc = new FileConduit (...); fc.attach (new ZipOutputFilter); fc.attach (new MungingOutputFilter);
Again, the last filter attached is the first one invoked when a block of content is actually written. Each filter has two additional methods that it may use to control behavior:
class FilterOutput : IFilterOutput { protected IFilterOutput next; void bind (IFilterOutput next) { this.next = next; } void unbind () { } }
The first method is invoked when the filter is attached to a conduit, while the second is invoked just before the conduit is closed. Both of these may be overridden by the filter for whatever purpose desired.
Note that an output filter can choose to sidestep writing to the conduit (per the usual case), and direct its output to somewhere else entirely. This mechanism supports the notion of 'piping' between multiple conduits, or between a conduit and something else entirely; as with the input-filter case, this is a bridging mechanism.
Definition at line 478 of file IConduit.d.
|
conduit-specific writer Reimplemented in Conduit, ConduitSink, and SocketConduit. |
|
Reimplemented in Conduit, ConduitSink, and SocketConduit. Referenced by SocketConduit::attach(), and Conduit::attach(). |
|
Reimplemented in Conduit, ConduitSink, and SocketConduit. Referenced by SocketConduit::VersionUseFreeList::closure(), Conduit::closure(), and ConduitSink::unbind(). |