dsg.smart
Interface StreamModule

All Known Implementing Classes:
SMBase

public interface StreamModule

Smart works by setting up simultaneous streams of data between the different components. The StreamModule interface defines the basic unit of development for Smart application code.

Stream modules --- also called simply modules --- are simply stream filters with zero or more inputs and zero or more outputs.

Outputs from one stream module are connected to inputs from the next. All stream modules run ``simultaneously'' in separate threads. The stream module API provides a select-type command to handle more than one input without polling.

Data passed between stream modules may come in any format. In general, we expect to pass serialized data.


Method Summary
 java.io.InputStream getInput(int i)
          Returns the stream attached to the ith input.
 int getNumInputs()
          How many inputs does this stream module have?
 int getNumOutputs()
          How many outputs does this stream module have?
 java.io.OutputStream getOutput(int i)
          Returns the output stream attached to the ith output.
 void run(SMContext con)
          Entry point --- should never exit.
 void setInput(int i, java.io.InputStream fin)
          Assigns input stream --- called by MIT code when connecting stream modules.
 void setOutput(int i, java.io.OutputStream fout)
          Assigns output stream --- called by MIT code when connecting stream modules.
 void stop()
          Generally called from a separate thread from run().
 

Method Detail

getNumInputs

public int getNumInputs()
How many inputs does this stream module have?


getNumOutputs

public int getNumOutputs()
How many outputs does this stream module have?


setInput

public void setInput(int i,
                     java.io.InputStream fin)
Assigns input stream --- called by MIT code when connecting stream modules.


getInput

public java.io.InputStream getInput(int i)
Returns the stream attached to the ith input.


setOutput

public void setOutput(int i,
                      java.io.OutputStream fout)
Assigns output stream --- called by MIT code when connecting stream modules.


getOutput

public java.io.OutputStream getOutput(int i)
Returns the output stream attached to the ith output.


stop

public void stop()
Generally called from a separate thread from run(). Cleans up by closing all upstream and downstream pipes, thus causing an exception in run(), which will then exit.


run

public void run(SMContext con)
Entry point --- should never exit. Stream modules are stopped from the Session interface. If it does exit, the system must stop downstream modules as well.

Parameters:
con - a context object, containing any Smart system calls one wishes to provide to the Stream Modules.
See Also:
Session