com.speckled.specksim.state
Class StateSink

java.lang.Object
  extended by com.speckled.specksim.state.StateSink
All Implemented Interfaces:
Configurable

@ConfigurableType(value="State")
public class StateSink
extends java.lang.Object
implements Configurable

Processes SimulatorState objects

Author:
ryanm

Field Summary
 StateFilterManager filterManager
          Manages the state filters
 StateProcessorManager processorManager
          Manages the state processors
 
Constructor Summary
StateSink(StateSource source)
          Builds a new StateSink
 
Method Summary
 void addStateListener(StateListener listener)
          Registers a listeners interest in this state.
 int findID(int id)
          Searches the state and returns the index of the speck with the supplied id.
 Configurator getConfigurator()
          Gets a Configurator object that describes and can manipulate the variables of this Configurable.
 long getPopulationStamp()
          Gets the current value of the population stamp.
 StateProcessor getProcessor(java.lang.String name)
          Gets a named StateProcessor, so that the output can be accessed
 SimulatorState getState()
          Gets the current state object
 StateFilter getStateFilter(java.lang.String name)
          Retrieves a filter based on its name
 boolean isIncluded(int index)
          Determines whether or not a given element should be included in any state processing, statistics gathering, visualisation and so on
 void refresh()
          Causes the state to be updated from the current StateSource, and the listeners to be notified
 void removeStateListener(StateListener listener)
          Registers a listener's boredom in this state.
 void setSource(StateSource source)
          Sets the source of SimulatorState objects
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filterManager

@SubConfigurable
public StateFilterManager filterManager
Manages the state filters


processorManager

@SubConfigurable
public StateProcessorManager processorManager
Manages the state processors

Constructor Detail

StateSink

public StateSink(StateSource source)
Builds a new StateSink

Parameters:
source - The source to use
Method Detail

refresh

public void refresh()
Causes the state to be updated from the current StateSource, and the listeners to be notified


setSource

public void setSource(StateSource source)
Sets the source of SimulatorState objects

Parameters:
source - The new source

getPopulationStamp

public long getPopulationStamp()
Gets the current value of the population stamp. This value is incremented every time the state is updated or the filters are altered. Beware that it may wrap around if you're running for long enough

Returns:
The population stamp

addStateListener

public void addStateListener(StateListener listener)
Registers a listeners interest in this state. Listeners will be informed when the state is updated

Parameters:
listener - The listener to register

removeStateListener

public void removeStateListener(StateListener listener)
Registers a listener's boredom in this state.

Parameters:
listener - The listener to remove

getProcessor

public StateProcessor getProcessor(java.lang.String name)
Gets a named StateProcessor, so that the output can be accessed

Parameters:
name - The name of the desired processor
Returns:
The processor, or null if there is no such processor

findID

public int findID(int id)
Searches the state and returns the index of the speck with the supplied id.

Parameters:
id - The speck id to search for
Returns:
The index of the speck, or -1 if there is no such speck currently resident

isIncluded

public boolean isIncluded(int index)
Determines whether or not a given element should be included in any state processing, statistics gathering, visualisation and so on

Parameters:
index - the index of the element to consider
Returns:
true if the element is to be included, false otherwise

getStateFilter

public StateFilter getStateFilter(java.lang.String name)
Retrieves a filter based on its name

Parameters:
name - The name of the desired filter
Returns:
The filter so named, or null if no such filter exists

getState

public SimulatorState getState()
Gets the current state object

Returns:
The SimulatorState object

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