ucar.unidata.view.sounding
Class ComputeCell

java.lang.Object
  extended by ucar.unidata.view.sounding.ComputeCell
Direct Known Subclasses:
AddCell, AirDensityProfileCell, AirTemperatureCell, BuoyancyProfileCell, DewPointExtractorCell, DomainEvaluatorCell, DomainExtractorCell, DryTrajectoryCell, EnergyFeatureCell, EnergyProfileCell, EvaluateIntegralCell, IntegrateCell, LayerMeanCell, LclPressureCell, LclTemperatureCell, MaxPressureCell, MixingRatioCell, MixingRatioProfileCell, PotentialTemperatureProfileCell, ProfileCleanerCell, ProfileCombinerCell, ProfileFeatureCell, RealEvaluatorCell, SelectorCell, TuplerCell, VirtualTemperatureProfileCell, WetTrajectoryCell

public abstract class ComputeCell
extends Object

Abstract, computational entity with one or more inputs and one output.

Version:
$Revision: 1.9 $ $Date: 2005/08/02 17:01:09 $
Author:
Steven R. Emmerson

Constructor Summary
protected ComputeCell(String name, DataReference[] inRefs, Data initValue)
          Constructs from a name for the instance and the input and output data references.
 
Method Summary
 void clean()
          Cleans this instance.
protected abstract  Data compute(Data[] datums)
          Computes the output data objects.
 boolean disableRef(DataReference ref)
          Disables an input data reference.
 void enableAllInputRefs()
          Enables all input data references.
 DataReference[] getInputRefs()
          Returns the input data references.
 DataReference getOutputRef()
          Returns the data references to the output data objects.
protected static FlatField noDataField(RealType rangeType)
          Convenience method for creating an empty atmospheric profile of a given parameter.
 String toString()
          Returns a string representation of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComputeCell

protected ComputeCell(String name,
                      DataReference[] inRefs,
                      Data initValue)
               throws RemoteVisADException,
                      VisADException,
                      RemoteException
Constructs from a name for the instance and the input and output data references. The name of the ActionImpl will be the name of this instance with the suffix ".action". The input and output data references arrays are cloned. Subclasses should invoke enableAllInputRefs() at the end of their construction to start the DataReferences-listening thread.

Parameters:
name - The name for the instance.
inRefs - The input DataReferences.
initValue - The initial value of the output data.
Throws:
RemoteVisADException - if initValue is a RemoteData.
NullPointerException - if any argument is null or if an input data reference is null.
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.
Method Detail

getInputRefs

public final DataReference[] getInputRefs()
Returns the input data references. The returned array is not backed by this instance.

Returns:
The input data references.

getOutputRef

public final DataReference getOutputRef()
Returns the data references to the output data objects. The array is not backed by this instance.

Returns:
The references to the output data objects.

enableAllInputRefs

public final void enableAllInputRefs()
                              throws VisADException,
                                     RemoteException
Enables all input data references. An enabled input data reference will trigger recomputation of the output data object when the referenced, input data object changes.

Throws:
NullPointerException - if an input data reference is null.
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.

disableRef

public final boolean disableRef(DataReference ref)
                         throws VisADException,
                                RemoteException
Disables an input data reference. A disabled input data reference will not trigger recomputation of the output data object when the referenced, input data object changes.

Parameters:
ref - The input data reference to disable.
Returns:
True if and only if the input data reference was enabled when this method was invoked.
Throws:
NullPointerException - if the argument is null.
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.

compute

protected abstract Data compute(Data[] datums)
                         throws TypeException,
                                VisADException,
                                RemoteException
Computes the output data objects. This method is invoked by this instance's ActionImpl. It is the subclass's responsibility of to set the output data references.

Parameters:
datums - The input data in the same order as during construction (i.e. datums[i] corresponds to inRefs[i].
Returns:
The output data objec corresponding to the input data.
Throws:
ClassCastException - if an input data reference has the wrong type of VisAD data object (e.g. a Real instead of a Field).
TypeException - if the internal details of a VisAD data object are wrong (e.g. incompatible unit).
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.

clean

public final void clean()
                 throws VisADException,
                        RemoteException
Cleans this instance. All data references are removed from this instance's ActionImpl and the action is stopped. This instance may be reused after invoking this method,

Throws:
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.

toString

public final String toString()
Returns a string representation of this instance. The instance's name is returned.

Overrides:
toString in class Object
Returns:
A string representation of this instance.

noDataField

protected static FlatField noDataField(RealType rangeType)
                                throws VisADException,
                                       RemoteException
Convenience method for creating an empty atmospheric profile of a given parameter.

Parameters:
rangeType - The type of parameter.
Returns:
An empty profile with the parameter as its range type.
Throws:
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.