fi.jyu.phys.grain.sort
Class GrainBaseSorter

java.lang.Object
  extended by fi.jyu.phys.grain.sort.GrainBaseSorter
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
GrainGreatSorter, GrainJuroGamSorter, GrainJuroGamTNTSorter, GrainPreJ2Sorter, GrainSolarCellSorter

public abstract class GrainBaseSorter
extends java.lang.Object
implements java.lang.Runnable

The base class for all Grain sort classes.

Author:
pajura

Field Summary
 GrainEvent event
          The current event.
 IHistogramFactory hfactory
          Histograms are created with this factory.
 ITupleFactory tfactory
          Tuples are created with this factory.
 ITree tree
          Histograms are stored here.
 
Constructor Summary
GrainBaseSorter()
          Creates a new instance of GrainGreatSorter
 
Method Summary
abstract  void finalise()
          Called when the thread is done.
abstract  void initialise()
          Initialises the internal structures of the base sorter.
abstract  void process()
          Processes the current event.
 void run()
           
 void setSave(boolean save)
          Reads a new event from EventStore and dispatches a process call.
 void setUp(java.util.concurrent.BlockingQueue es, ITree tr, IHistogramFactory hf, ITupleFactory tf)
          Sets up the infrastructure of the base sorter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

event

public GrainEvent event
The current event.


tree

public ITree tree
Histograms are stored here.


hfactory

public IHistogramFactory hfactory
Histograms are created with this factory.


tfactory

public ITupleFactory tfactory
Tuples are created with this factory.

Constructor Detail

GrainBaseSorter

public GrainBaseSorter()
Creates a new instance of GrainGreatSorter

Method Detail

setUp

public void setUp(java.util.concurrent.BlockingQueue es,
                  ITree tr,
                  IHistogramFactory hf,
                  ITupleFactory tf)
Sets up the infrastructure of the base sorter. Should not be called explicitly.

Parameters:
es -
tr -
hf -

initialise

public abstract void initialise()
Initialises the internal structures of the base sorter. Histograms etc. should be created here.


setSave

public void setSave(boolean save)
Reads a new event from EventStore and dispatches a process call. Stops, calls finelise, stores spectra and exits when EventStore runs dry. Should not be called explicitly.


run

public void run()
Specified by:
run in interface java.lang.Runnable

process

public abstract void process()
Processes the current event. The real work is done here.


finalise

public abstract void finalise()
Called when the thread is done. Free resources (files etc.) here if any are claimed. Histograms are saved elsewhere.