ptolemy.actor.gt.controller
Class ModelParameter

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.kernel.util.AbstractSettableAttribute
              extended by ptolemy.data.expr.Variable
                  extended by ptolemy.data.expr.Parameter
                      extended by ptolemy.actor.gt.controller.ModelParameter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Initializable, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, ValueListener

public class ModelParameter
extends Parameter
implements Initializable

A parameter in the Ptera-based model transformation that temporarily stores the model to be transformed.

Since:
Ptolemy II 8.0
Version:
$Id: ModelParameter.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Thomas Huining Feng
See Also:
Serialized Form
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.data.expr.Variable
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
private  java.util.List<Initializable> _initializables
          List of objects whose (pre)initialize() and wrapup() methods should be slaved to these.
private  CompositeEntity _model
          The model in this parameter.
private  ActorToken _token
          The most recently created ActorToken.
private  long _tokenVersion
          The version of the ActorToken.
 
Fields inherited from class ptolemy.data.expr.Variable
_currentExpression, _needsEvaluation, _parserScope, _parseTreeValid, _valueListeners
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
ModelParameter(NamedObj container, java.lang.String name)
          Construct a parameter with the given name contained by the specified entity.
 
Method Summary
 void addInitializable(Initializable initializable)
          Add the specified object to the list of objects whose preinitialize(), initialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object.
 java.lang.Object clone(Workspace workspace)
          Clone the parameter.
 void exportMoML(java.io.Writer output, int depth, java.lang.String name)
          Write a MoML description of this parameter, unless this parameter is not persistent.
 java.lang.String getExpression()
          Return an empty string.
 CompositeEntity getModel()
          Get the model stored in this parameter.
 Token getToken()
          Get the token of this parameter, which is an ActorToken containing the model.
 void initialize()
          Initialize this model parameter.
 void modelChanged()
          React to change of the model in this parameter.
 void preinitialize()
          Preinitialize this model parameter and set the current model to be null.
 void removeInitializable(Initializable initializable)
          Remove the specified object from the list of objects whose preinitialize(), initialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object.
 void setContainer(NamedObj container)
          Set the new container of this parameter.
 void setExpression(java.lang.String expression)
          Do nothing.
 void setModel(CompositeEntity model)
          Set the model in this parameter.
 void setToken(Token token)
          Set the model in this parameter with an ActorToken.
 void wrapup()
          Set the model in this parameter to be null.
 
Methods inherited from class ptolemy.data.expr.Parameter
addChoice, getChoices, removeAllChoices, removeChoice
 
Methods inherited from class ptolemy.data.expr.Variable
_description, _evaluate, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, getDeclaredType, getFreeIdentifiers, getParserScope, getScope, getScope, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, invalidate, isKnown, isLazy, isStringMode, isTypeAcceptable, removeValueListener, reset, setLazy, setName, setParseTreeEvaluator, setStringMode, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, setVisibility, stringRepresentation, toString, typeConstraintList, typeConstraints, validate, 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, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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.Settable
getDisplayName
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName
 

Field Detail

_initializables

private transient java.util.List<Initializable> _initializables
List of objects whose (pre)initialize() and wrapup() methods should be slaved to these.


_model

private CompositeEntity _model
The model in this parameter.


_token

private ActorToken _token
The most recently created ActorToken.


_tokenVersion

private long _tokenVersion
The version of the ActorToken.

Constructor Detail

ModelParameter

public ModelParameter(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

addInitializable

public void addInitializable(Initializable initializable)
Add the specified object to the list of objects whose preinitialize(), initialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object.

Specified by:
addInitializable in interface Initializable
Parameters:
initializable - The object whose methods should be invoked.
See Also:
removeInitializable(Initializable)

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the parameter. 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).

Overrides:
clone in class Variable
Parameters:
workspace - The workspace in which to place the cloned variable.
Returns:
The cloned variable.
Throws:
java.lang.CloneNotSupportedException - Not thrown in this base class.
See Also:
Object.clone()

exportMoML

public void exportMoML(java.io.Writer output,
                       int depth,
                       java.lang.String name)
                throws java.io.IOException
Write a MoML description of this parameter, unless this parameter is not persistent.

Specified by:
exportMoML in interface MoMLExportable
Overrides:
exportMoML in class Parameter
Parameters:
output - The output stream to write to.
depth - The depth in the hierarchy, to determine indenting.
name - The name to use instead of the current name.
Throws:
java.io.IOException - If an I/O error occurs.
See Also:
NamedObj.isPersistent()

getExpression

public java.lang.String getExpression()
Return an empty string.

Specified by:
getExpression in interface Settable
Overrides:
getExpression in class Variable
Returns:
An empty string.
See Also:
setExpression(String)

getModel

public CompositeEntity getModel()
Get the model stored in this parameter.

Returns:
The model.
See Also:
setModel(CompositeEntity)

getToken

public Token getToken()
               throws IllegalActionException
Get the token of this parameter, which is an ActorToken containing the model.

Overrides:
getToken in class Variable
Returns:
The token.
Throws:
IllegalActionException - If the ActorToken cannot be created.
See Also:
setToken(Token)

initialize

public void initialize()
                throws IllegalActionException
Initialize this model parameter.

Specified by:
initialize in interface Initializable
Throws:
IllegalActionException - If thrown by other initializables associated to this parameter.

modelChanged

public void modelChanged()
React to change of the model in this parameter.


preinitialize

public void preinitialize()
                   throws IllegalActionException
Preinitialize this model parameter and set the current model to be null.

Specified by:
preinitialize in interface Initializable
Throws:
IllegalActionException - If thrown by other initializables associated to this parameter.

removeInitializable

public void removeInitializable(Initializable initializable)
Remove the specified object from the list of objects whose preinitialize(), initialize(), and wrapup() methods should be invoked upon invocation of the corresponding methods of this object. If the specified object is not on the list, do nothing.

Specified by:
removeInitializable in interface Initializable
Parameters:
initializable - The object whose methods should no longer be invoked.
See Also:
addInitializable(Initializable)

setContainer

public void setContainer(NamedObj container)
                  throws IllegalActionException,
                         NameDuplicationException
Set the new container of this parameter.

Overrides:
setContainer in class Variable
Parameters:
container - The new container.
Throws:
IllegalActionException - If the container will not accept a variable as its attribute, or this variable and the container are not in the same workspace, or the proposed container would result in recursive containment.
NameDuplicationException - If the container already has an attribute with the name of this variable.
See Also:
Attribute.getContainer()

setExpression

public void setExpression(java.lang.String expression)
Do nothing.

Specified by:
setExpression in interface Settable
Overrides:
setExpression in class Variable
Parameters:
expression - The new expression.
See Also:
getExpression()

setModel

public void setModel(CompositeEntity model)
Set the model in this parameter.

Parameters:
model - The new model.
See Also:
getModel()

setToken

public void setToken(Token token)
              throws IllegalActionException
Set the model in this parameter with an ActorToken.

Overrides:
setToken in class Variable
Parameters:
token - The ActorToken.
Throws:
IllegalActionException - If the token is not an ActorToken.
See Also:
getToken()

wrapup

public void wrapup()
            throws IllegalActionException
Set the model in this parameter to be null.

Specified by:
wrapup in interface Initializable
Throws:
IllegalActionException - If thrown by other initializables associated to this parameter.