edu.buffalo.fs7.qsymbol2
Class GateContainer

java.lang.Object
  |
  +--edu.buffalo.fs7.qsymbol2.GateContainer
All Implemented Interfaces:
Steppable

public class GateContainer
extends java.lang.Object
implements Steppable

class wrapping a Mathlib Gate object. This class provides the ability of grouping gates together and hierarchical arrange them. It uses the addtional information provided by optional GateProperty objects to provide multiple iterations of gates and gate groups, gates with errors and as well handles the simulatin of decoherence.

Gates are grouped with the help of their name qualifier. For example the gates group1.gate0 and group1.gate1 would belong to the same group. Since this class is responsible for holding groups of gates it implements the Steppable interface with which it administers the sequential operation of gates.

See Also:
Steppable, Gate

Field Summary
protected  java.util.Vector childs
          holds child containers
protected  int currentIteration
          holds the current iteration of the gate container
protected  java.lang.String description
          description of the gate container
protected  java.lang.String gateName
          holds the name of the gate in case this container is a leaf
protected  java.lang.String name
          name of the gate container
protected  GateContainer parent
          parent container
protected  int stepChild
          holds the child which "has" the current step
protected  boolean stepFocus
          holds the step focus.
 
Constructor Summary
GateContainer(GateContainer parent, java.lang.String name, java.lang.String gateName)
          constructs a gate container
 
Method Summary
 void addChildContainer(GateContainer child)
          adds a given gate container as a child to this gate container.
 GateContainer addContainerIfPossible(GateContainer nextContainer)
          this is a special method to add a single container column to an existing container and merge matching groups.
 void adjustGateContainer(java.lang.String oldTopLevel)
          adjusts the child container if the top level container was renamed.
 void complete()
          sets the step handling of the gate container to a completed state
 boolean containsGateContainer(java.lang.String name)
          determines whether a gate container qualified by the given string parameter is a child of this gatecontainer.
 GateContainer getChildContainer(int i)
          returns a specified child container. null if index out of range.
 int getChildCount()
          returns the number of direct childs
 java.util.Enumeration getChilds()
          returns the direct childs in an Enumeration object.
 java.util.Enumeration getChildsOnLevel(int level)
          returns childs on a specified level in an Enumeration object.
 int getContainerDepth()
          returns the depth of this container
 int getContainerLevel()
          returns the container level
 double getCurrentDecayProbability()
           
 double getCurrentDecoherenceRate()
           
 Matrix getCurrentErrorMatrix()
          returns the error modifier (2x2 matrix) for the current gate or null if none is specified
 Gate getCurrentGate()
          returns the gate which corresponds to the current step.
 int getCurrentIteration()
          returns the current iteration of this gate container.
 java.lang.String getDescription()
          returns the description of this gate container as displayed by the tooltip
 int getDimension()
          returns the dimension of the first gate contained by this container
 java.lang.String getFullName()
          returns the full name of the gate container
 Gate getGate()
          returns gate if container is leaf container otherwise null
 int getLeafCount()
          determines the number of leaves parented by this container and its child containers
 java.util.Enumeration getLeaves()
          returns an enumeration of the leaves parented by this container and its childs.
 int getMaxIteration()
          returns the maximum number of iterations for this gate container.
 GateContainer getParent()
          returns the parent of the gate container
 GateProperty getPropertyObject()
          returns the property object
 int getStep()
          returns the current step within this gate container
protected  int getStepChild()
          returns the step child index
 int getStepCount()
          returns the number of steps contained in this gatecontainer.
 java.lang.String getTopLevelName()
          returns the top level name of the gate container.
 boolean hasStepFocus()
          returns wheter the gate container has the step focus
 void insertChildContainer(GateContainer child, int pos)
          inserts a given gate container to a certain position of the child containers.
 boolean isLeafContainer()
          determines whether container is a leaf container and therefore holds a gate
 boolean isStep()
          returns true if the current gate container holds the current step
protected  void levelDown(java.lang.String newTopLevel)
          brings a child container one level down.
protected  void levelUp(java.lang.String oldTopLevel)
          brings a child container one level up.
 void removeChildContainer(GateContainer child)
          removes a child container specified by child.
 void removeLeafGateContainer(java.lang.String name)
          removes a leaf container specified by name
 void reset()
          resets the step handling of the gate container
 void setCurrentIteration(int currentIteration)
          sets the value of the current iteration
 void setGate(java.lang.String gateName)
          sets the gate hold by this gatecontainer. only applicable to leaf containers.
 void setParent(GateContainer parent)
          sets the parent of the gate container
 void setPropertyObject(GateProperty gateProperty)
          registers the given gateProperty object as the property object of this gate containers.
 void setStepFocus(boolean stepFocus)
          sets the step focus to this gate container.
 void setTopLevelName(java.lang.String name)
          sets the top level name of the gate container.
 boolean stepBackward()
          decreases the step by one.
 boolean stepForward()
          increases the step by one.
 java.lang.String toString()
          returns the most important information of the gate containe as a string.
 java.util.Enumeration ungroup()
          ungroups a parent container into its child components.
 void updateDescription()
          updates gate container description
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

childs

protected java.util.Vector childs
holds child containers

gateName

protected java.lang.String gateName
holds the name of the gate in case this container is a leaf

stepChild

protected int stepChild
holds the child which "has" the current step

currentIteration

protected int currentIteration
holds the current iteration of the gate container

stepFocus

protected boolean stepFocus
holds the step focus. Only one gate container at a time is allowed to hold the step focus.

name

protected java.lang.String name
name of the gate container

description

protected java.lang.String description
description of the gate container

parent

protected GateContainer parent
parent container
Constructor Detail

GateContainer

public GateContainer(GateContainer parent,
                     java.lang.String name,
                     java.lang.String gateName)
constructs a gate container
Parameters:
parent - the parent gate container or null
level - the level of the gate container
name - the full name of the gate container
gateName - the name of the gate
Method Detail

containsGateContainer

public boolean containsGateContainer(java.lang.String name)
determines whether a gate container qualified by the given string parameter is a child of this gatecontainer.
Parameters:
name - name of variable for gatecontainer
Returns:
true if child

addChildContainer

public void addChildContainer(GateContainer child)
adds a given gate container as a child to this gate container.

insertChildContainer

public void insertChildContainer(GateContainer child,
                                 int pos)
inserts a given gate container to a certain position of the child containers.

removeChildContainer

public void removeChildContainer(GateContainer child)
removes a child container specified by child.
Parameters:
child - the child container to be removed

getChildCount

public int getChildCount()
returns the number of direct childs

getChildContainer

public GateContainer getChildContainer(int i)
returns a specified child container. null if index out of range.
Parameters:
number - of child starting with 0

getChilds

public java.util.Enumeration getChilds()
returns the direct childs in an Enumeration object.

getChildsOnLevel

public java.util.Enumeration getChildsOnLevel(int level)
returns childs on a specified level in an Enumeration object.
Parameters:
level - child level

removeLeafGateContainer

public void removeLeafGateContainer(java.lang.String name)
removes a leaf container specified by name

getLeaves

public java.util.Enumeration getLeaves()
returns an enumeration of the leaves parented by this container and its childs.

getLeafCount

public int getLeafCount()
determines the number of leaves parented by this container and its child containers
Returns:
number of leafs

ungroup

public java.util.Enumeration ungroup()
ungroups a parent container into its child components. The child container are updated according to the new structure and returned as an enumeration.

levelUp

protected void levelUp(java.lang.String oldTopLevel)
brings a child container one level up. The property objects and the gate variables are adjusted accordingly.
Parameters:
oldTopLevel - the old top level name of the gate container

levelDown

protected void levelDown(java.lang.String newTopLevel)
brings a child container one level down. The property objects and the gate variables are adjusted accordingly.
Parameters:
oldTopLevel - the old top level name of the gate container

addContainerIfPossible

public GateContainer addContainerIfPossible(GateContainer nextContainer)
this is a special method to add a single container column to an existing container and merge matching groups.

getParent

public GateContainer getParent()
returns the parent of the gate container

setParent

public void setParent(GateContainer parent)
sets the parent of the gate container

adjustGateContainer

public void adjustGateContainer(java.lang.String oldTopLevel)
adjusts the child container if the top level container was renamed.

getContainerLevel

public int getContainerLevel()
returns the container level

getContainerDepth

public int getContainerDepth()
returns the depth of this container

toString

public java.lang.String toString()
returns the most important information of the gate containe as a string.
Overrides:
toString in class java.lang.Object

getPropertyObject

public GateProperty getPropertyObject()
returns the property object

setPropertyObject

public void setPropertyObject(GateProperty gateProperty)
registers the given gateProperty object as the property object of this gate containers.

isLeafContainer

public boolean isLeafContainer()
determines whether container is a leaf container and therefore holds a gate

getDimension

public int getDimension()
returns the dimension of the first gate contained by this container

getTopLevelName

public java.lang.String getTopLevelName()
returns the top level name of the gate container. E.g. group.gate0 --> group

setTopLevelName

public void setTopLevelName(java.lang.String name)
sets the top level name of the gate container.

getFullName

public java.lang.String getFullName()
returns the full name of the gate container

getCurrentIteration

public int getCurrentIteration()
returns the current iteration of this gate container. Used by the graphics routines to plot the header.

setCurrentIteration

public void setCurrentIteration(int currentIteration)
sets the value of the current iteration

getMaxIteration

public int getMaxIteration()
returns the maximum number of iterations for this gate container.

getGate

public Gate getGate()
returns gate if container is leaf container otherwise null

setGate

public void setGate(java.lang.String gateName)
sets the gate hold by this gatecontainer. only applicable to leaf containers. Name of the variable that represents the gate.

getCurrentGate

public Gate getCurrentGate()
returns the gate which corresponds to the current step. It returns null if the step is larger than the gates hold by this gate container.
Returns:
the current gate

getCurrentErrorMatrix

public Matrix getCurrentErrorMatrix()
returns the error modifier (2x2 matrix) for the current gate or null if none is specified

getCurrentDecoherenceRate

public double getCurrentDecoherenceRate()

getCurrentDecayProbability

public double getCurrentDecayProbability()

getDescription

public java.lang.String getDescription()
returns the description of this gate container as displayed by the tooltip
Returns:
string of description

updateDescription

public void updateDescription()
updates gate container description

setStepFocus

public void setStepFocus(boolean stepFocus)
sets the step focus to this gate container. This property is used to determine whether the current step is in this container

hasStepFocus

public boolean hasStepFocus()
returns wheter the gate container has the step focus

getStepCount

public int getStepCount()
returns the number of steps contained in this gatecontainer. It is the number calculated by adding up all childs and their repetition.
Specified by:
getStepCount in interface Steppable

getStepChild

protected int getStepChild()
returns the step child index

stepForward

public boolean stepForward()
increases the step by one.
Specified by:
stepForward in interface Steppable
Returns:
true if step was successful, false if this step leaves the gatecontainer

stepBackward

public boolean stepBackward()
decreases the step by one.
Specified by:
stepBackward in interface Steppable
Returns:
true if step was successful, false if this step leaves the gatecontainer

getStep

public int getStep()
returns the current step within this gate container
Specified by:
getStep in interface Steppable
Returns:
-1 if the gate container does not have the step focus

isStep

public boolean isStep()
returns true if the current gate container holds the current step

reset

public void reset()
resets the step handling of the gate container
Specified by:
reset in interface Steppable

complete

public void complete()
sets the step handling of the gate container to a completed state