Package ptolemy.actor.gt
Class IterativeParameter
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.kernel.util.AbstractSettableAttribute
-
- ptolemy.data.expr.Variable
-
- ptolemy.data.expr.Parameter
-
- ptolemy.actor.gt.IterativeParameter
-
- All Implemented Interfaces:
java.lang.Cloneable,MatchCallback,ValueIterator,HasTypeConstraints,Typeable,Changeable,Debuggable,DebugListener,Derivable,ModelErrorHandler,MoMLExportable,Moveable,Nameable,Settable,ValueListener
public class IterativeParameter extends Parameter implements MatchCallback, ValueIterator
A special parameter in the pattern that can take various values in pattern. matching. In a transformation, the pattern matching algorithm may try to use all the allowed values one by one by invoking the methodsinitial()andnext(), until either the latter method throws anIllegalActionExceptionor the pattern matching terminates. With this parameter, it is possible to define a pattern with variable structures, which depend on the values of this parameter.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Thomas Huining Feng
- Pt.AcceptedRating:
- Red (tfeng)
- Pt.ProposedRating:
- Yellow (tfeng)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classIterativeParameter.ConstraintViolationExceptionThe exception to denote that the constraint is violated and no more values are available.static classIterativeParameter.ModeThe modes of this parameter.-
Nested classes/interfaces inherited from class ptolemy.data.expr.Variable
Variable.CircularDependencyError, Variable.VariableScope
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
Nested classes/interfaces inherited from interface ptolemy.kernel.util.Settable
Settable.Visibility
-
-
Field Summary
Fields Modifier and Type Field Description ParameterconstraintThe constraint that all values must satisfy.ParameterinitialThe initial value.ChoiceParametermodeThe mode of this parameter.ParameternextThe next value (computed based on the current value).-
Fields inherited from class ptolemy.data.expr.Variable
_currentExpression, _needsEvaluation, _parserScope, _parseTreeValid, _suppressVariableSubstitution, _valueListeners
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
-
-
Constructor Summary
Constructors Constructor Description IterativeParameter(NamedObj container, java.lang.String name)Construct a parameter with the given name contained by the specified entity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_validateConstraint()Validate the constraint.voidattributeChanged(Attribute attribute)React to a change in an attribute.java.lang.Objectclone(Workspace workspace)Clone the variable.booleanfoundMatch(GraphMatcher matcher)A routine to be called when a match is found in the graph matching.Tokeninitial()Set the value of this parameter to be the initial value, and return that initial value.Tokennext()Set the value of this parameter to be the next acceptable value, and return that value.java.util.Collection<?>validate()If this variable is not lazy (the default) then evaluate the expression contained in this variable, and notify any value dependents.-
Methods inherited from class ptolemy.data.expr.Parameter
addChoice, exportMoML, getChoices, removeAllChoices, removeChoice
-
Methods inherited from class ptolemy.data.expr.Variable
_description, _evaluate, _getCurrentExpression, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, getDeclaredType, getExpression, getFreeIdentifiers, getParserScope, getScope, getScope, getToken, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, invalidate, isKnown, isLazy, isStringMode, isSuppressVariableSubstitution, isTypeAcceptable, removeValueListener, reset, setContainer, setExpression, setLazy, setName, setParseTreeEvaluator, setStringMode, setSuppressVariableSubstitution, setToken, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, setValueListenerAsWeakDependency, setVisibility, stringRepresentation, toString, typeConstraintList, typeConstraints, valueChanged
-
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
-
Methods inherited from interface ptolemy.kernel.util.Settable
addValueListener, getDefaultExpression, getDisplayName, getExpression, getValueAsString, getVisibility, removeValueListener, setExpression, setVisibility
-
Methods inherited from interface ptolemy.actor.gt.ValueIterator
getToken, setToken
-
-
-
-
Field Detail
-
constraint
public Parameter constraint
The constraint that all values must satisfy.
-
initial
public Parameter initial
The initial value.
-
mode
public ChoiceParameter mode
The mode of this parameter.- See Also:
IterativeParameter.Mode
-
next
public Parameter next
The next value (computed based on the current value).
-
-
Constructor Detail
-
IterativeParameter
public IterativeParameter(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a parameter with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This parameter will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. The object is not added to the list of objects in the workspace unless the container is null. Increment the version of the workspace.- Parameters:
container- The container.name- The name of the parameter.- Throws:
IllegalActionException- If the parameter is not of an acceptable class for the container.NameDuplicationException- If the name coincides with a parameter already in the container.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
React to a change in an attribute. This method is called by a contained attribute when its value changes. In this base class, the method does nothing. In derived classes, this method may throw an exception, indicating that the new attribute value is invalid. It is up to the caller to restore the attribute to a valid value if an exception is thrown.- Overrides:
attributeChangedin classVariable- Parameters:
attribute- The attribute that changed.- Throws:
IllegalActionException- If the change is not acceptable to this container (not thrown in this base class).
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the variable. This creates a new variable containing the same token (if the value was set with setToken()) or the same (unevaluated) expression, if the expression was set with setExpression(). The list of variables added to the scope is not cloned; i.e., the clone has an empty scope. The clone has the same static type constraints (those given by setTypeEquals() and setTypeAtMost()), but none of the dynamic type constraints (those relative to other variables).
-
foundMatch
public boolean foundMatch(GraphMatcher matcher)
A routine to be called when a match is found in the graph matching. The graph matcher is passed in as the parameter, and the current match can be obtained by callingGraphMatcher.getMatchResult(). This match result should not be kept, however, because it may be changed by future matching operations. To keep a copy of this result, invokeMatchResult.clone()and keep the cloned copy. The return value indicates whether the match is the one looked for. If it is true, the matching will terminate after this routine returns, and no more match result will be reported.- Specified by:
foundMatchin interfaceMatchCallback- Parameters:
matcher- The graph matcher.- Returns:
- Whether the matching should terminate right away.
-
initial
public Token initial() throws IllegalActionException
Set the value of this parameter to be the initial value, and return that initial value.- Specified by:
initialin interfaceValueIterator- Returns:
- The initial value.
- Throws:
IllegalActionException- If the initial value cannot be set.
-
next
public Token next() throws IllegalActionException
Set the value of this parameter to be the next acceptable value, and return that value.- Specified by:
nextin interfaceValueIterator- Returns:
- The next value.
- Throws:
IllegalActionException- If the next value cannot be set.
-
validate
public java.util.Collection<?> validate() throws IllegalActionExceptionIf this variable is not lazy (the default) then evaluate the expression contained in this variable, and notify any value dependents. If those are not lazy, then they too will be evaluated. Also, if the variable is not lazy, then notify its container, if there is one, by calling its attributeChanged() method.If this variable is lazy, then mark this variable and any of its value dependents as needing evaluation and for any value dependents that are not lazy, evaluate them. Note that if there are no value dependents, or if they are all lazy, then this will not result in evaluation of this variable, and hence will not ensure that the expression giving its value is valid. Call getToken() or getType() to accomplish that.
- Specified by:
validatein interfaceSettable- Overrides:
validatein classVariable- Returns:
- The current list of value listeners, which are evaluated as a consequence of this call to validate().
- Throws:
IllegalActionException- If this variable or a variable dependent on this variable cannot be evaluated (and is not lazy) and the model error handler throws an exception. Also thrown if the change is not acceptable to the container.
-
_validateConstraint
protected void _validateConstraint() throws IllegalActionExceptionValidate the constraint.- Throws:
IllegalActionException- If the constraint is violated, or if the current value of the parameter cannot be retrieved.
-
-