fern.network
Class DefaultAmountManager

java.lang.Object
  extended by fern.network.DefaultAmountManager
All Implemented Interfaces:
AmountManager

public class DefaultAmountManager
extends Object
implements AmountManager

Default implementation of an amount manager, that stores the amounts in arrays.

Author:
erhard

Constructor Summary
DefaultAmountManager(Network net)
          Creates an AmountManager for a given network
 
Method Summary
 long getAmount(int species)
          Gets the current amount of a species.
 void performReaction(int reaction, int times)
          Reflects a (multiple) firing of a reaction by adjusting the populations of the reactants and the products.
 void resetAmount()
          Resets the amount of each species to the initial amount retrieved by the networks AnnotationManager.
 void rollback()
          Restore the amount array from the recently saved one.
 void save()
          Makes a copy of the amount array.
 void setAmount(int species, long amount)
          Sets the current amount of a species.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAmountManager

public DefaultAmountManager(Network net)
Creates an AmountManager for a given network

Parameters:
net - the network
Method Detail

performReaction

public void performReaction(int reaction,
                            int times)
Reflects a (multiple) firing of a reaction by adjusting the populations of the reactants and the products. If a population becomes negative, a RuntimeException is thrown.

Specified by:
performReaction in interface AmountManager
Parameters:
reaction - the index of the reaction fired
times - the number of firings

getAmount

public long getAmount(int species)
Gets the current amount of a species.

Specified by:
getAmount in interface AmountManager
Parameters:
species - index of the species
Returns:
actual amount of the species

setAmount

public void setAmount(int species,
                      long amount)
Sets the current amount of a species.

Specified by:
setAmount in interface AmountManager
Parameters:
species - index of the species

resetAmount

public void resetAmount()
Resets the amount of each species to the initial amount retrieved by the networks AnnotationManager. This is called whenever a Simulator is started.

Specified by:
resetAmount in interface AmountManager

save

public void save()
Makes a copy of the amount array.

Specified by:
save in interface AmountManager

rollback

public void rollback()
Restore the amount array from the recently saved one.

Specified by:
rollback in interface AmountManager