tenua.simulator
Interface DataGenerator

All Superinterfaces:
java.lang.Runnable
All Known Implementing Classes:
AbstractDataGenerator, Mechanism, StringDataGenerator

public interface DataGenerator
extends java.lang.Runnable

Interface that represents something that generates data, in the form of an array of doubles; this is a copy of the internal data and can be modified at will. The same number of output data are generated at each pass This is a natural to put in an independent Thread, so an implementation should (but I can't find anyway to enforce this) call Thread.yield at least once through every pass, and check for Thread.isInterrupted and stop generating data, and call done on each listener if true. An implementation may support getting a Memento of its internal state (See Design Patterns) to restart the data generator or watch it working if it also exposes the format of the Memento

Author:
Daniel Wachsstock

Nested Class Summary
static interface DataGenerator.Listener
          a class that listens for data being generated
 
Method Summary
 void addListener(DataGenerator.Listener listener)
          add a DataGenerator.Listener to this DataGenerator's list
 java.lang.Object getMemento()
           
 java.util.List getNames()
           
 void removeListener(DataGenerator.Listener listener)
          remove a given DataGenerator.Listener from this DataGenerator's list
 void start(java.lang.Object memento)
          starts (or restarts) the data generator
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

start

void start(java.lang.Object memento)
starts (or restarts) the data generator

Parameters:
memento - a Memento of the internal state of the data generator, or null to start afresh. Calls startingUp on each listener either way

a Memento returned by getMemento() for the same DataGenerator is guarranteed not to throw and will continue the data generation from "close" to where it was generated. "close" is implementation-specific

Throws:
java.lang.UnsupportedOperationException - if a non-null Memento is passed and this implementation does not support Mementos
java.lang.IllegalArgumentException - if the Memento is not supported by this DataGenerator

getNames

java.util.List getNames()
Returns:
the names of the output data. If there are no names, it will be an list of empty strings (not null!), which will at least give the caller the number of outputs

getMemento

java.lang.Object getMemento()
Returns:
the current internal state; what this means is implementation specific. It also does not guarrantee that the data generator can be started up in exactly the same state it is in now, just that it will be "close" in some sense and it would be possible to reset it to that Memento with start(Object)
Throws:
java.lang.UnsupportedOperationException - if this implementation does not support Mementos

addListener

void addListener(DataGenerator.Listener listener)
add a DataGenerator.Listener to this DataGenerator's list


removeListener

void removeListener(DataGenerator.Listener listener)
remove a given DataGenerator.Listener from this DataGenerator's list