ptolemy.actor.gt.ingredients.operations
Class Operation

java.lang.Object
  extended by ptolemy.actor.gt.GTIngredient
      extended by ptolemy.actor.gt.ingredients.operations.Operation
Direct Known Subclasses:
AttributeOperation, DynamicAttributeOperation, PortCreationOperation, PortRemovalOperation, RenameOperation

public abstract class Operation
extends GTIngredient

An operation to update an object in the host model.

Since:
Ptolemy II 8.0
Version:
$Id: Operation.java 54815 2009-06-30 05:18:27Z tfeng $
Author:
Thomas Huining Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.actor.gt.GTIngredient
GTIngredient.FieldIterator
 
Field Summary
protected  ParseTreeWriter _parseTreeWriter
          A parse tree writer to output the contents of a parse tree.
 
Fields inherited from class ptolemy.actor.gt.GTIngredient
FIELD_SEPARATOR
 
Constructor Summary
Operation(GTIngredientList owner, int elementCount)
          Construct an operation within the given list as its owner containing a given number of elements.
 
Method Summary
protected  ASTPtLeafNode _evaluate(ASTPtRootNode parseTree, ParseTreeEvaluator evaluator, ParserScope scope)
          Given a parse tree of a Ptolemy expression, evaluate it in the given scope and return a new constant AST node that has the result as its value.
abstract  ChangeRequest getChangeRequest(Pattern pattern, Replacement replacement, MatchResult matchResult, NamedObj patternObject, NamedObj replacementObject, NamedObj hostObject)
          Get the change request to update the object in the host model.
 
Methods inherited from class ptolemy.actor.gt.GTIngredient
_decodeBooleanField, _decodeStringField, _encodeBooleanField, _encodeStringField, _escapeElementString, _findMatchingParen, _findSeparator, _unescapeElementString, disableAll, enableAll, getElements, getOwner, getValue, getValues, isApplicable, isEnabled, setEnabled, setValue, setValues, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_parseTreeWriter

protected ParseTreeWriter _parseTreeWriter
A parse tree writer to output the contents of a parse tree. For a node in the parse tree that is a string constant, it outputs the result of stringValue() instead of toString().

Constructor Detail

Operation

public Operation(GTIngredientList owner,
                 int elementCount)
Construct an operation within the given list as its owner containing a given number of elements. All elements are enabled at the beginning.

Parameters:
owner - The list as the owner of the constructed GTIngredientList.
elementCount - The number of elements that the GTIngredient has.
Method Detail

getChangeRequest

public abstract ChangeRequest getChangeRequest(Pattern pattern,
                                               Replacement replacement,
                                               MatchResult matchResult,
                                               NamedObj patternObject,
                                               NamedObj replacementObject,
                                               NamedObj hostObject)
                                        throws IllegalActionException
Get the change request to update the object in the host model.

Parameters:
pattern - The pattern of the transformation rule.
replacement - The replacement of the transformation rule.
matchResult - The match result.
patternObject - The object in the pattern, or null.
replacementObject - The object in the replacement that corresponds to the object in the pattern.
hostObject - The object in the host model corresponding to the object in the replacement.
Returns:
The change request.
Throws:
IllegalActionException - If error occurs in generating the change request.

_evaluate

protected ASTPtLeafNode _evaluate(ASTPtRootNode parseTree,
                                  ParseTreeEvaluator evaluator,
                                  ParserScope scope)
                           throws IllegalActionException
Given a parse tree of a Ptolemy expression, evaluate it in the given scope and return a new constant AST node that has the result as its value.

Parameters:
parseTree - The parse tree.
evaluator - The evaluator to be used.
scope - The scope.
Returns:
The new AST node with the result as its value.
Throws:
IllegalActionException - If an error occurs during the evaluation.