com.speckled.specksim.state
Class StateRecorder

java.lang.Object
  extended by com.speckled.specksim.state.StateRecorder
All Implemented Interfaces:
Configurable, StateListener

@ConfigurableType(value="State Recorder")
@Description(value="Records a sequence of state objects for later consumption")
public class StateRecorder
extends java.lang.Object
implements Configurable, StateListener

Records a series of state objects for later consumption

Author:
ryanm

Constructor Summary
StateRecorder()
          Constructs a new StateRecorder that will be manually handed SimulatorState objects to be recorded
StateRecorder(StateSink sink)
          Constructs a new StateRecorder that will automatically record the state objects that pass through a StateSink
 
Method Summary
 Configurator getConfigurator()
          Gets a Configurator object that describes and can manipulate the variables of this Configurable.
 java.io.File getOutput()
          Gets the current output file
 void setOutput(java.io.File file)
          Changes the output file.
 void startRecording()
          Starts recording state objects.
 void stateRefreshed()
          Called when the associated state is refreshed
 void stopRecording()
          Stops recording incoming state objects
 long writeState(SimulatorState state)
          Write a SimulatorState object to the stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateRecorder

public StateRecorder()
Constructs a new StateRecorder that will be manually handed SimulatorState objects to be recorded


StateRecorder

public StateRecorder(StateSink sink)
Constructs a new StateRecorder that will automatically record the state objects that pass through a StateSink

Parameters:
sink - The sink that receives the state objects to be recorded
Method Detail

setOutput

@ConfigurableVariable(value="Output file")
public void setOutput(java.io.File file)
Changes the output file. The current file will be closed as a result

Parameters:
file - The new output file.

getOutput

@ConfigurableVariable(value="Output file")
@Priority(value=1)
public java.io.File getOutput()
Gets the current output file

Returns:
The output file

startRecording

@ConfigurableVariable(value="Start recording")
@Priority(value=2)
public void startRecording()
Starts recording state objects.


stopRecording

@ConfigurableVariable(value="Stop recording")
@Priority(value=3)
public void stopRecording()
Stops recording incoming state objects


writeState

public long writeState(SimulatorState state)
Write a SimulatorState object to the stream

Parameters:
state - The state object
Returns:
The number of bytes written to the stream

stateRefreshed

public void stateRefreshed()
Description copied from interface: StateListener
Called when the associated state is refreshed

Specified by:
stateRefreshed in interface StateListener

getConfigurator

public Configurator getConfigurator()
Description copied from interface: Configurable
Gets a Configurator object that describes and can manipulate the variables of this Configurable. This method must only return null if the Configurable object is Annotated such that an AnnotatedConfigurator can be built from it.

Specified by:
getConfigurator in interface Configurable
Returns:
A configurator object, or null if annotated