public class DataPipeline extends java.lang.Object implements SourceCallback
VehicleDataSource
call the
receive(VehicleMessage)
method on the this class when new
values arrive. The DataPipeline then passes this value on to all currently
registered data sinks.
The Pipeline can have an optional Operator, which implements a few callbacks
to check the status of the pipeline - e.g. if some source in the pipeline is
active.Modifier and Type | Class and Description |
---|---|
static interface |
DataPipeline.Operator |
Constructor and Description |
---|
DataPipeline() |
DataPipeline(DataPipeline.Operator operator) |
Modifier and Type | Method and Description |
---|---|
VehicleDataSink |
addSink(VehicleDataSink sink)
Add a new sink to the pipeline.
|
VehicleDataSource |
addSource(VehicleDataSource source)
Add a new source to the pipeline.
|
void |
clearSinks()
Remove and stop all sinks in the pipeline.
|
void |
clearSources()
Remove and stop all sources in the pipeline.
|
KeyedMessage |
get(MessageKey key)
Return the last received value for the keyed message if known.
|
int |
getMessageCount() |
java.util.List<VehicleDataSink> |
getSinks() |
java.util.List<VehicleDataSource> |
getSources() |
boolean |
isActive() |
boolean |
isActive(VehicleDataSource skipSource)
Return true if at least one source is active.
|
void |
receive(VehicleMessage message)
Accept new values from data sources and send it out to all registered
sinks.
|
void |
removeSink(VehicleDataSink sink)
Remove a previously added sink from the pipeline.
|
void |
removeSource(VehicleDataSource source)
Remove a previously added source from the pipeline.
|
void |
sourceConnected(VehicleDataSource source)
At least one source is active - notify the operator.
|
void |
sourceDisconnected(VehicleDataSource source)
At least one source is not active - if all sources are inactive, notify
the operator.
|
void |
stop()
Clear all sources and sinks from the pipeline and stop all of them.
|
java.lang.String |
toString() |
public DataPipeline()
public DataPipeline(DataPipeline.Operator operator)
public void receive(VehicleMessage message)
receive
in interface SourceCallback
message
- the new measurement.public VehicleDataSink addSink(VehicleDataSink sink)
public void removeSink(VehicleDataSink sink)
VehicleDataSink.stop()
method
is also called.sink
- if the value is null, it is ignored.public VehicleDataSource addSource(VehicleDataSource source)
public void removeSource(VehicleDataSource source)
source
- if the value is null, it is ignored.public java.util.List<VehicleDataSource> getSources()
public java.util.List<VehicleDataSink> getSinks()
public void stop()
public void clearSources()
public void clearSinks()
public KeyedMessage get(MessageKey key)
key
- the key of the message to retrieve, if any available.public int getMessageCount()
public boolean isActive()
public boolean isActive(VehicleDataSource skipSource)
skipSource
- don't consider this data source when determining if the
pipeline is active.public void sourceDisconnected(VehicleDataSource source)
sourceDisconnected
in interface SourceCallback
public void sourceConnected(VehicleDataSource source)
sourceConnected
in interface SourceCallback
public java.lang.String toString()
toString
in class java.lang.Object