evolution
Class Evolution


public class Evolution

Represent evolution (time).

Stereotype singleton

Inner Class Summary
 (package private) classEvolution.ClockThread
          The clock as a seperate thread.
 (package private) classEvolution.LivingBeingTester
          For debugging.

Constructor Summary
 protected Evolution()
          Construct an Evolution object.

Method Summary
 synchronized voidderegister(Evolver e)
          Deregister an Evolver.
 protected Mapdifference(Map m1, Map m2)
          Calculate the difference of two (String, Double) maps.
 ListgetEvolverList()
          Get the list of evolvers.
 static EvolutiongetInst()
          Get the singleton instance.
 doublegetTimeFactor()
          Get the time factor.
 static voidinitialize()
          Initialize the instance of this singleton.
 booleanisRunning()
          Is evolution running?
 static voidmain(String[] args)
          For debugging.
 voidpause()
          Pause the evolution.
 synchronized voidregister(Evolver e)
          Register an Evolver.
 voidresume()
          Resume the evolution.
 voidsetTimeFactor(double factor)
          Set the time factor.
 protected voidtest(int ttl)
          For debugging.
 protected synchronized voidtick()
          This method is called on regular basis when running.

Constructor Detail

Evolution

protected Evolution()
Construct an Evolution object. The new object will be in pause mode.
Method Detail

deregister

public synchronized void deregister(Evolver e)
Deregister an Evolver.

difference

protected Map difference(Map m1, Map m2)
Calculate the difference of two (String, Double) maps. Returns a (String, Double) Map.

getEvolverList

public List getEvolverList()
Get the list of evolvers.

getInst

public static Evolution getInst()
Get the singleton instance. Precondition: Evolution.initialize() must have been called.

getTimeFactor

public double getTimeFactor()
Get the time factor.

initialize

public static void initialize()
Initialize the instance of this singleton.

isRunning

public boolean isRunning()
Is evolution running?

main

public static void main(String[] args)
throws java.lang.InterruptedException
For debugging.

pause

public void pause()
Pause the evolution.

register

public synchronized void register(Evolver e)
Register an Evolver. Every time the clock ticks evolve() will be called on the Evolver.

resume

public void resume()
Resume the evolution.

setTimeFactor

public void setTimeFactor(double factor)
Set the time factor.

test

protected void test(int ttl)
For debugging.

tick

protected synchronized void tick()
This method is called on regular basis when running.

Association Links

to Class java.util.List

A list of evolvers that produce energy.

to Class java.util.List

A list of evolvers that can't produce energy.

to Class evolution.Evolution.ClockThread

The clock thread.

to Class evolution.Evolution

The singleton instance.

a gvijf production