ptolemy.domains.fsm.kernel
Class RelationList

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.util.Attribute
          extended byptolemy.domains.fsm.kernel.RelationList
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable

public class RelationList
extends Attribute

A RelationList contains a list of relations of a guard expression. It provides facilities to access the former and current information of each relation of a guard expression during its evaluation. The information includes type and difference information. (See ParseTreeEvaluatorForGuardExpression for detailed explanation of type and difference.) This attribute is non-persistent and will not be exported into MoML.

This class is designed to be used with ParseTreeEvaluatorForGuardExpression. The common usage would be like:

// Construct a relation list for a transition. // The first argument of the constructor is a // transition. _relationList = new RelationList(this, "relationList");

// Associate the relation list with the ParseTreeEvaluatorForGuardExpression _parseTreeEvaluator = new ParseTreeEvaluatorForGuardExpression(_relationList);

Since:
Ptolemy II 4.0
Version:
$Id: RelationList.java,v 1.13 2004/04/13 05:12:56 cxh Exp $
Author:
Haiyang Zheng
See Also:
ParseTreeEvaluatorForGuardExpression, Transition, Serialized Form
Accepted Rating:
Red (hyzheng)
Proposed Rating:
Red (hyzheng)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
RelationList(Transition transition, java.lang.String name)
          Construct a relation list with the given name contained by the specified transition.
 
Method Summary
 void addRelation(int type, double difference)
          Construct a relation node with the given type and difference information of a relation, and add it to the end of the relation list.
 void clearRelationList()
          Clear the relation list by resetting each relation node.
 void commitRelationValues()
          Update the relation list by updating each relation node.
 void destroy()
          Destroy the relation list by deleting all its elements.
 double getFormerMaximumDistance()
          Return the former difference of the relation which has the maximum current difference.
 boolean hasEvent()
          Return true if there is some event caused by some relation type change.
 boolean isEmpty()
          Return true if the relation list is empty.
 int length()
          Return the number of relations in the relation list.
 double maximumDifference()
          Iterating the relation list and get the maximum current difference of all the relations.
 int maximumDifferenceIndex()
          Return the index of the relation with the maximum current difference.
 void setRelation(int relationIndex, int type, double difference)
          Update the relation in the relation list referred by the relation index argument with the given type and difference information.
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, getContainer, setContainer, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RelationList

public RelationList(Transition transition,
                    java.lang.String name)
             throws IllegalActionException,
                    NameDuplicationException
Construct a relation list with the given name contained by the specified transition. The transition argument must not be null, or a NullPointerException will be thrown. This action will use the workspace of the transition for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace. This attribute is a non-persistent and it will not be exported into MoML file.

Parameters:
transition - The transition container.
name - The name of this relation list.
Throws:
IllegalActionException - If the relation list is not of an acceptable class for the container, or if the name contains a period.
NameDuplicationException - If the transition already has an attribute with the name.
Method Detail

addRelation

public void addRelation(int type,
                        double difference)
Construct a relation node with the given type and difference information of a relation, and add it to the end of the relation list.

Parameters:
type - The relation type of the relation.
difference - The difference of the relation.

clearRelationList

public void clearRelationList()
Clear the relation list by resetting each relation node.


commitRelationValues

public void commitRelationValues()
Update the relation list by updating each relation node.


destroy

public void destroy()
Destroy the relation list by deleting all its elements.


getFormerMaximumDistance

public double getFormerMaximumDistance()
Return the former difference of the relation which has the maximum current difference.

Returns:
The former distance of a relation.

hasEvent

public boolean hasEvent()
Return true if there is some event caused by some relation type change. Return True If there is some event detected.


isEmpty

public boolean isEmpty()
Return true if the relation list is empty.

Returns:
True If the relation list is empty.

length

public int length()
Return the number of relations in the relation list.

Returns:
the number of relations in the relation list.

maximumDifference

public double maximumDifference()
Iterating the relation list and get the maximum current difference of all the relations.

Returns:
maximumDistance The maximum current distance.

maximumDifferenceIndex

public int maximumDifferenceIndex()
Return the index of the relation with the maximum current difference.

Returns:
index The index of the relation with maximum current distance.

setRelation

public void setRelation(int relationIndex,
                        int type,
                        double difference)
Update the relation in the relation list referred by the relation index argument with the given type and difference information.

Parameters:
relationIndex - The position of the relation in the relation list.
type - The current type of the relation.
difference - The current difference of the relation.