gov.nist.antd.optical.algorithm
Class AlgorithmContainer

java.lang.Object
  |
  +--gov.nist.antd.optical.AbstractObject
        |
        +--gov.nist.antd.optical.algorithm.AlgorithmContainer

public final class AlgorithmContainer
extends AbstractObject

Only one instance of this container is existent per network. The container has knowledge about the whole topology by referencing to the Net instance of the simulation framework. The container contains "centralized" algorithms. This algorithms are working on the whole topology. While running such an algorithm the topology must not be changed from the outside.

 This class was developed at the National Institute of Standards and
 Technology by employees of the Federal Government in the course of
 their official duties. Pursuant to title 17 Section 105 of the United
 States Code this software is not subject to copyright protection and
 is in the public domain.
 NIST assumes no responsibility whatsoever for its use by other parties,
 and makes no guarantees, expressed or implied, about its quality,
 reliability, or any other characteristic.
 
We would appreciate acknowledgement if the software is used.
NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.

Author:
borchert
, rouil

Field Summary
private  Algorithm[] algorithms
          The list of the algorithms available for this OXC.
private  Net net
          The net that contains the topology.
private static java.util.Hashtable NETWORKS
          The global container.
private  int noAlgorithms
          The number of stored algorithms in the array.
 
Fields inherited from class gov.nist.antd.optical.AbstractObject
INITIAL_ARRAY_SIZE
 
Constructor Summary
private AlgorithmContainer()
          Default constructor.
 
Method Summary
 void addAlgorithm(Algorithm algorithm)
          Adds the given algorithm to the container.
 void clear()
          Removes all assigned algorithms of the container.
protected  java.lang.Object[] createArray(int size)
          Creates an array of the specified size.
 Algorithm[] getAlgorithms()
          Returns an array containing all algorithms.
 Algorithm getByName(java.lang.String name)
          This method returns the centralized algorithm with the specified name.
static AlgorithmContainer getContainer(Net net)
          Determines the AlgorithmContainer that belongs to the network.
 Net getNet()
          Determines the net instance.
 int getSize()
          Returns the number of Algorithms stored in the Container.
 void removeAlgorithm(Algorithm algorithm)
          Removes the given algorithm.
 void removeAlgorithm(java.lang.String name)
          Removes the specified algorithm.
static void removeContainer(Net net)
          Remove the containers of the given net.
 void setNet(Net net)
          Set the net object.
protected  void setNoElements(int size)
          Set the number of elements.
 
Methods inherited from class gov.nist.antd.optical.AbstractObject
addElement, clear, isElementOf, removeElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NETWORKS

private static final java.util.Hashtable NETWORKS
The global container.


noAlgorithms

private int noAlgorithms
The number of stored algorithms in the array.


net

private Net net
The net that contains the topology.


algorithms

private Algorithm[] algorithms
The list of the algorithms available for this OXC.

Constructor Detail

AlgorithmContainer

private AlgorithmContainer()
Default constructor.

Method Detail

getContainer

public static AlgorithmContainer getContainer(Net net)
Determines the AlgorithmContainer that belongs to the network. If no AlgorithmContainer exist this method creates one and returns it.

Parameters:
net - The Network the container belongs to.
Returns:
The AlgorithmContainer.

removeContainer

public static void removeContainer(Net net)
Remove the containers of the given net.

Parameters:
net - The network to remove.

addAlgorithm

public void addAlgorithm(Algorithm algorithm)
                  throws AlgorithmException
Adds the given algorithm to the container.

Parameters:
algorithm - the algorithm that has to be added.
Throws:
AlgorithmException - if the algorithm is already added.

clear

public void clear()
Removes all assigned algorithms of the container.


getAlgorithms

public Algorithm[] getAlgorithms()
Returns an array containing all algorithms.

Returns:
An array with the algorithms or an array of the length == 0 if no algorithm is existent.

getByName

public Algorithm getByName(java.lang.String name)
This method returns the centralized algorithm with the specified name.

Parameters:
name - the name of the algorithm. The name is case sensitive.
Returns:
The algorithm or null.

getSize

public int getSize()
Returns the number of Algorithms stored in the Container.

Returns:
number of algorithms stored in the container.

removeAlgorithm

public void removeAlgorithm(Algorithm algorithm)
                     throws AlgorithmException
Removes the given algorithm.

Parameters:
algorithm - the Algorithm that has to be removed.
Throws:
AlgorithmException - the specified algorithm does not exist.

removeAlgorithm

public void removeAlgorithm(java.lang.String name)
                     throws AlgorithmException
Removes the specified algorithm.

Parameters:
name - the name of the algorithm.
Throws:
AlgorithmException - the algorithm does not exist in the container.

getNet

public Net getNet()
Determines the net instance.

Returns:
the net object or null.

setNet

public void setNet(Net net)
Set the net object.

Parameters:
net - the instance of net.

createArray

protected java.lang.Object[] createArray(int size)
Creates an array of the specified size.

Specified by:
createArray in class AbstractObject
Parameters:
size - the given size.
Returns:
an array of CentralizedAlgorithm with the specified size.

setNoElements

protected void setNoElements(int size)
Set the number of elements.

Specified by:
setNoElements in class AbstractObject
Parameters:
size - the new number of elements.