org.magnos.data.var
Class DoubleVar

java.lang.Object
  extended by org.magnos.data.AbstractData
      extended by org.magnos.data.var.AbstractVar<java.lang.Double>
          extended by org.magnos.data.var.DoubleVar
All Implemented Interfaces:
Data, Var<java.lang.Double>

public class DoubleVar
extends AbstractVar<java.lang.Double>

A Var with a double value.

Author:
Philip Diffenderfer

Field Summary
static int SIZE
           
 
Constructor Summary
DoubleVar()
          Instantiates a new DoubleVar.
DoubleVar(double value)
          Instantiates a new DoubleVar.
DoubleVar(Store store, int location)
          Instantiates a new DoubleVar.
DoubleVar(Store store, int location, double value)
          Instantiates a new DoubleVar.
 
Method Summary
 double add(double x)
          Adds the given value to this var and returns the result.
 Data copy()
          Creates a clone of this data.
 double get()
          Returns the current value of the var.
 java.lang.Double getValue()
          Returns the value of this var as it was the last time this variable was read from a store at the location (and maybe with an offset) or as it was set with the setValue method.
 double max(double x)
          Sets the var to the max between this var and the value.
 double min(double x)
          Sets the var to the min between this var and the value.
 double mul(double x)
          Multiplies the given value to this var and returns the result.
 void onRead(int location, Store store)
          Reads this data from the given store at the given location.
 void onWrite(int location, Store store)
          Writes this data to the given store at the given location.
 void put(double value)
          Sets the value of this var and writes it to the store.
 void set(double value)
          Sets the value of this var, but does not write it to the store.
 void setValue(java.lang.Double value)
          Sets the value of this var without writing the value to a store.
 double take()
          Returns the value of this var by first reading it from the store.
 
Methods inherited from class org.magnos.data.var.AbstractVar
equals, hashCode, putValue, takeValue, toString
 
Methods inherited from class org.magnos.data.AbstractData
getActualLocation, getLocation, getParent, getSize, getStore, read, read, read, read, setLocation, setParent, setStore, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.magnos.data.Data
getActualLocation, getLocation, getParent, getSize, getStore, read, read, read, read, setLocation, setParent, setStore, write, write, write, write
 

Field Detail

SIZE

public static final int SIZE
See Also:
Constant Field Values
Constructor Detail

DoubleVar

public DoubleVar()
Instantiates a new DoubleVar.


DoubleVar

public DoubleVar(double value)
Instantiates a new DoubleVar.

Parameters:
value - The initial value.

DoubleVar

public DoubleVar(Store store,
                 int location)
Instantiates a new DoubleVar.

Parameters:
store - The intial store.
location - The intial location.

DoubleVar

public DoubleVar(Store store,
                 int location,
                 double value)
Instantiates a new DoubleVar.

Parameters:
store - The initial store.
location - The initial location.
value - The initial value.
Method Detail

get

public double get()
Returns the current value of the var.

Returns:
The current value.

add

public double add(double x)
Adds the given value to this var and returns the result.

Parameters:
x - The value to add to this var.
Returns:
The result of the operation.

max

public double max(double x)
Sets the var to the max between this var and the value.

Parameters:
x - The value to take the max of with this var.
Returns:
The result of the operation.

min

public double min(double x)
Sets the var to the min between this var and the value.

Parameters:
x - The value to take the min of with this var.
Returns:
The result of the operation.

mul

public double mul(double x)
Multiplies the given value to this var and returns the result.

Parameters:
x - The value to multiply by this var.
Returns:
The result of the operation.

set

public void set(double value)
Sets the value of this var, but does not write it to the store.

Parameters:
value - The new value.

put

public void put(double value)
Sets the value of this var and writes it to the store.

Parameters:
value - The new value.

take

public double take()
Returns the value of this var by first reading it from the store.

Returns:
The value of this var.

getValue

public java.lang.Double getValue()
Returns the value of this var as it was the last time this variable was read from a store at the location (and maybe with an offset) or as it was set with the setValue method.

Returns:
The last value read.

setValue

public void setValue(java.lang.Double value)
Sets the value of this var without writing the value to a store.

Parameters:
value - The new value to set.

onRead

public void onRead(int location,
                   Store store)
Reads this data from the given store at the given location.

Specified by:
onRead in class AbstractData
Parameters:
location - The offset in bytes from the beginning of the store to read from.
store - The store to read from.

onWrite

public void onWrite(int location,
                    Store store)
Writes this data to the given store at the given location.

Specified by:
onWrite in class AbstractData
Parameters:
location - The offset in bytes from the beginning of the store to write to.
store - The store to write to.

copy

public Data copy()
Creates a clone of this data. The resulting data will be of the same type, have the same location, the same store, and have other similar attributes to this type.

Returns:
A clone of this data.