I
- type of the input valuesO
- type of the output valuespublic interface SignalProcessor<I,O>
Lets you process data using a push approach, that is controlling the flow of data
from the beginning of a pipeline (preferably with a SignalPump
).
This means that you can push data into the process(Object)
method without expecting a result as return value. Instead, a graph of registered SignalProcessors
is processing the provided data. Only when you call flush()
the final processing step is done and
final results have to be computed. Those results may be collected from the tree's leafs
with the leaf object's getOutput()
method.
If you have a rather simple pipeline, that does not contain any forks, you might want to use the
pull model, offered by SignalPullProcessor
.
SignalPullProcessor
,
SignalPump
Modifier and Type | Method and Description |
---|---|
<O2> SignalProcessor<O,O2> |
connectTo(SignalProcessor<O,O2> signalProcessor)
Connects this processor to another processor to forward processed data to.
|
<O2> SignalProcessor<O,O2> |
disconnectFrom(SignalProcessor<O,O2> signalProcessor)
Disconnects a child processor.
|
void |
flush()
Asks to complete all pending operations.
|
SignalProcessor<O,?>[] |
getConnectedProcessors()
Lists all connected processors.
|
Object |
getId()
Arbitrary object to identify a processor.
|
O |
getOutput()
First calls
flush() , then returns the pending output, should there be any. |
void |
process(I i)
Asks this processor to work on the provided data and pipe the
output to the connected processors' own
process(Object) method.Implementing methods must not modify or hold on to the provided data. |
void process(I i) throws IOException
process(Object)
method.Object.clone()
method.
It is the responsibility of implementing classes to call the process(Object)
method of any connected processors. To manage connected processors classes may want
to use a SignalProcessorSupport
instance.i
- data to processIOException
- if a processing error occursgetConnectedProcessors()
void flush() throws IOException
flush()
method.IOException
- if a processing error occursO getOutput() throws IOException
flush()
, then returns the pending output, should there be any.
Note that this call may only succeed once to preserve memory.null
is returnedIOException
- if a processing error occursObject getId()
getOutput()
.SignalPump.pump()
<O2> SignalProcessor<O,O2> connectTo(SignalProcessor<O,O2> signalProcessor)
O2
- output type of the processor we want to connect tosignalProcessor
- processordisconnectFrom(SignalProcessor)
,
getConnectedProcessors()
,
SignalPipeline
<O2> SignalProcessor<O,O2> disconnectFrom(SignalProcessor<O,O2> signalProcessor)
O2
- output type of the processor we want to disconnect fromsignalProcessor
- processorconnectTo(SignalProcessor)
,
getConnectedProcessors()
SignalProcessor<O,?>[] getConnectedProcessors()
null
disconnectFrom(SignalProcessor)
,
connectTo(SignalProcessor)
Copyright © 2011–2020 tagtraum industries incorporated. All rights reserved.