SimObs
Class Resource

java.lang.Object
  |
  +--SimObs.Resource

public class Resource
extends java.lang.Object

Used to represent simulation objects that need not be represented as individual entities since they are identical and can be taken and returned by objects that are represented as entities. A major theme of most discrete simulations is resource contention, in which two or more entities require the same resource. In effect, a resource is a pool of identical items.


Constructor Summary
Resource()
          Alternative constructor for an empty resource pool.
Resource(java.lang.String thisName, int total)
          Simple constructor that give the resource a name and sets up the initial amount in the pool.
 
Method Summary
 void add(int more)
          Adds extra resource units to this resource pool.
 void commit(int thisAmount)
          Commits thisAmount from the freeAmount available in this resource pool.
 int getAmount()
          Returns with the total amount in this resource pool.
 int getFreeAmount()
          Returns with the no of units currently unused in this resource pool.
 void makeAvail(int thisAmount)
          Release thisAmount of resource, thus increasing freeAmount by thisAmount.
 void setAmount(int thisAmount)
          Sets the amount in this resource.
 void setFreeAmount(int thisAmount)
          Sets the freeAmount in this resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Resource

public Resource(java.lang.String thisName,
                int total)
Simple constructor that give the resource a name and sets up the initial amount in the pool. Sets all amounts as initially available.

Resource

public Resource()
Alternative constructor for an empty resource pool.
Method Detail

add

public void add(int more)
Adds extra resource units to this resource pool. The extra are all made available.

getFreeAmount

public int getFreeAmount()
Returns with the no of units currently unused in this resource pool.

setFreeAmount

public void setFreeAmount(int thisAmount)
Sets the freeAmount in this resource. DANGEROUS, but needed if the constructor used has no parameters.

getAmount

public int getAmount()
Returns with the total amount in this resource pool. Includes both free resource and that currently committed.

setAmount

public void setAmount(int thisAmount)
Sets the amount in this resource. DANGEROUS, but needed if the constructor used has no parameters.

commit

public void commit(int thisAmount)
Commits thisAmount from the freeAmount available in this resource pool. Throws a fatal error if insufficient resource is available to meet the demand.

makeAvail

public void makeAvail(int thisAmount)
Release thisAmount of resource, thus increasing freeAmount by thisAmount. Throws a fatal error if not enough resource is available to meet this demand.