org.magnos.data
Interface Var<E>

Type Parameters:
E - The type of variable.
All Superinterfaces:
Data
All Known Implementing Classes:
AbstractVar, BooleanVar, ByteVar, DoubleVar, FloatVar, IntVar, LongVar, ShortVar, StringVar, UByteVar, UIntVar, UShortVar

public interface Var<E>
extends Data

A fixed size variable that can be read and written to and from a store. The value of the variable can be set or gotten lazily, such that the value is not read or written immediately, the last value is returned or updated. The value of the variable can also be put or taken which will do a read and write immediately from the store and then return the value.

Author:
Philip Diffenderfer

Method Summary
 E 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.
 boolean putValue(E newValue)
          Sets the value of this var and writes it to the store.
 void setValue(E newValue)
          Sets the value of this var without writing the value to a store.
 E takeValue()
          Returns the value of this var by reading it from the store and updating the cached value.
 
Methods inherited from interface org.magnos.data.Data
copy, getActualLocation, getLocation, getParent, getSize, getStore, read, read, read, read, setLocation, setParent, setStore, write, write, write, write
 

Method Detail

getValue

E 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

void setValue(E newValue)
Sets the value of this var without writing the value to a store.

Parameters:
newValue - The new value to set.

takeValue

E takeValue()
Returns the value of this var by reading it from the store and updating the cached value. If there is a problem reading the value from the store this will throw a RuntimeException and not update the cached value.

Returns:
The value read from the store.

putValue

boolean putValue(E newValue)
Sets the value of this var and writes it to the store.

Parameters:
newValue - The value to write to the store.