ptolemy.actor.gt
Class StateMatcher

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.domains.modal.kernel.State
                      extended by ptolemy.actor.gt.StateMatcher
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, GTEntity, Initializable, TypedActor, ConfigurableEntity, Changeable, Configurable, Debuggable, DebugListener, Derivable, DropTargetHandler, Flowable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, ValueListener

public class StateMatcher
extends State
implements GTEntity, TypedActor, ValueListener

A matcher to match a state in an FSM controller or an event in a Ptera controller.

Since:
Ptolemy II 6.1
Version:
$Id: StateMatcher.java 55886 2009-10-19 00:34:57Z eal $
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.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  CausalityInterface _causalityInterface
          The causality interface, if it has been created.
private  Director _causalityInterfaceDirector
          The director for which the causality interface was created.
private static java.util.List<?> _EMPTY_LIST
          An empty list.
private static java.util.Set<Inequality> _EMPTY_SET
          An empty set.
private  java.util.Set<java.lang.String> _labelSet
          Cache of the label set.
private  long _version
          The workspace version the last time when _labelSet was updated.
 GTIngredientsAttribute criteria
          The attribute containing all the criteria in a list (GTIngredientList).
 GTIngredientsEditor.Factory editorFactory
          The editor factory for ingredients in this matcher.
 GTIngredientsAttribute operations
          The attribute containing all the operations in a list (GTIngredientList).
 PatternObjectAttribute patternObject
          The attribute that specifies the name of the corresponding entity in the pattern.
 
Fields inherited from class ptolemy.domains.modal.kernel.State
incomingPort, isFinalState, isInitialState, outgoingPort, refinementName, saveRefinementsInConfigurer
 
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.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
StateMatcher(CompositeEntity container, java.lang.String name)
          Construct a state with the given name contained by the specified composite entity.
 
Method Summary
 void addInitializable(Initializable initializable)
          Do nothing because a state matcher is not supposed to contain any initializable.
 java.lang.Object clone(Workspace workspace)
          Clone the actor into the specified workspace.
 void createReceivers()
          Create receivers for all necessary ports.
 void fire()
          Do nothing.
 CausalityInterface getCausalityInterface()
          Return a causality interface for this actor.
 GTIngredientsAttribute getCriteriaAttribute()
          Return the attribute that stores all the criteria for this matcher.
 java.lang.String getDefaultIconDescription()
          Return null.
 Director getDirector()
          Return null.
 Director getExecutiveDirector()
          Return null.
 Manager getManager()
          Return null.
 GTIngredientsAttribute getOperationsAttribute()
          Return the attribute that stores all the operations for this matcher.
 PatternObjectAttribute getPatternObjectAttribute()
          Return the attribute that stores the name of the corresponding entity in the pattern of the same TransformationRule, if this entity is in the replacement, or null otherwise.
 void initialize()
          Do nothing.
 java.util.List<?> inputPortList()
          Return an empty list.
 boolean isFireFunctional()
          Return true because prefire and fire do nothing.
 boolean isStrict()
          Return false.
 int iterate(int count)
          Do nothing and return 0.
 java.util.Set<java.lang.String> labelSet()
          Return the set of names of ingredients contained in this entity that can be resolved.
 boolean match(NamedObj object)
          Return true if the given object is an instance of State (either the one in the deprecated FSM domain or the one in modal model since Ptolemy 8.0).
 Receiver newReceiver()
          Return null.
 java.util.List<?> outputPortList()
          Return an empty list.
 boolean postfire()
          Do nothing and return false.
 boolean prefire()
          Do nothing and return false.
 void preinitialize()
          Do nothing.
 void removeInitializable(Initializable initializable)
          Do nothing.
 void setContainer(CompositeEntity container)
          Specify the container, adding the entity to the list of entities in the container.
 void stop()
          Do nothing.
 void stopFire()
          Do nothing.
 void terminate()
          Do nothing.
 java.util.Set<Inequality> typeConstraints()
          Return an empty list.
 void updateAppearance(GTIngredientsAttribute attribute)
          Update appearance of this entity.
 void valueChanged(Settable settable)
          React to the fact that the specified Settable has changed.
 void wrapup()
          Do nothing.
 
Methods inherited from class ptolemy.domains.modal.kernel.State
_exportMoMLContents, attributeChanged, configure, dropObject, getConfigurer, getConfigureSource, getConfigureText, getIncomingPort, getObjectInRefinement, getOutgoingPort, getRefinement, nonpreemptiveTransitionList, preemptiveTransitionList
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_addPort, _adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _removePort, _validateSettables, connectedPortList, connectedPorts, connectionsChanged, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, 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.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

criteria

public GTIngredientsAttribute criteria
The attribute containing all the criteria in a list (GTIngredientList).


editorFactory

public GTIngredientsEditor.Factory editorFactory
The editor factory for ingredients in this matcher.


operations

public GTIngredientsAttribute operations
The attribute containing all the operations in a list (GTIngredientList).


patternObject

public PatternObjectAttribute patternObject
The attribute that specifies the name of the corresponding entity in the pattern.


_EMPTY_LIST

private static final java.util.List<?> _EMPTY_LIST
An empty list.


_EMPTY_SET

private static final java.util.Set<Inequality> _EMPTY_SET
An empty set.


_causalityInterface

private CausalityInterface _causalityInterface
The causality interface, if it has been created.


_causalityInterfaceDirector

private Director _causalityInterfaceDirector
The director for which the causality interface was created.


_labelSet

private java.util.Set<java.lang.String> _labelSet
Cache of the label set.


_version

private long _version
The workspace version the last time when _labelSet was updated.

Constructor Detail

StateMatcher

public StateMatcher(CompositeEntity container,
                    java.lang.String name)
             throws IllegalActionException,
                    NameDuplicationException
Construct a state with the given name contained by the specified composite entity. The container argument must not be null, or a NullPointerException will be thrown. This state 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. Increment the version of the workspace. This constructor write-synchronizes on the workspace.

Parameters:
container - The container.
name - The name of the state.
Throws:
IllegalActionException - If the state cannot be contained by the proposed container.
NameDuplicationException - If the name coincides with that of an entity already in the container.
Method Detail

addInitializable

public void addInitializable(Initializable initializable)
Do nothing because a state matcher is not supposed to contain any initializable.

Specified by:
addInitializable in interface Initializable
Parameters:
initializable - The initializable.
See Also:
Initializable.removeInitializable(Initializable)

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. Set a type constraint that the output type is the same as the that of input.

Overrides:
clone in class State
Parameters:
workspace - The workspace for the new object.
Returns:
A new actor.
Throws:
java.lang.CloneNotSupportedException - If a derived class has has an attribute that cannot be cloned.
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

createReceivers

public void createReceivers()
                     throws IllegalActionException
Create receivers for all necessary ports. In this implementation no receivers will be created

Specified by:
createReceivers in interface Actor
Throws:
IllegalActionException - If any port throws it.
See Also:
AtomicActor.createReceivers(), CompositeActor.createReceivers()

fire

public void fire()
          throws IllegalActionException
Do nothing.

Specified by:
fire in interface Executable
Throws:
IllegalActionException - Not thrown in this class.

getCausalityInterface

public CausalityInterface getCausalityInterface()
Return a causality interface for this actor. In this base class, if there is a director, we delegate to the director to return a default causality interface. Otherwise, we return an instance of CausalityInterface with BooleanDependency.OTIMES_IDENTITY as its default. This declares the dependency between input ports and output ports of an actor to be true, the multiplicative identity. If this is called multiple times, the same object is returned each time unless the director has changed since the last call, in which case a new object is returned.

Specified by:
getCausalityInterface in interface Actor
Returns:
A representation of the dependencies between input ports and output ports.

getCriteriaAttribute

public GTIngredientsAttribute getCriteriaAttribute()
Return the attribute that stores all the criteria for this matcher.

Specified by:
getCriteriaAttribute in interface GTEntity
Returns:
The attribute that stores all the criteria.

getDefaultIconDescription

public java.lang.String getDefaultIconDescription()
Return null.

Specified by:
getDefaultIconDescription in interface GTEntity
Returns:
null.

getDirector

public Director getDirector()
Return null.

Specified by:
getDirector in interface Actor
Returns:
null.

getExecutiveDirector

public Director getExecutiveDirector()
Return null.

Specified by:
getExecutiveDirector in interface Actor
Returns:
null.

getManager

public Manager getManager()
Return null.

Specified by:
getManager in interface Actor
Returns:
null.

getOperationsAttribute

public GTIngredientsAttribute getOperationsAttribute()
Return the attribute that stores all the operations for this matcher.

Specified by:
getOperationsAttribute in interface GTEntity
Returns:
The attribute that stores all the operations.

getPatternObjectAttribute

public PatternObjectAttribute getPatternObjectAttribute()
Return the attribute that stores the name of the corresponding entity in the pattern of the same TransformationRule, if this entity is in the replacement, or null otherwise.

Specified by:
getPatternObjectAttribute in interface GTEntity
Returns:
The attribute that stires the name of the corresponding entity.
See Also:
labelSet()

initialize

public void initialize()
                throws IllegalActionException
Do nothing.

Specified by:
initialize in interface Initializable
Throws:
IllegalActionException - Not thrown in this class.

inputPortList

public java.util.List<?> inputPortList()
Return an empty list.

Specified by:
inputPortList in interface Actor
Returns:
An empty list.

isFireFunctional

public boolean isFireFunctional()
Return true because prefire and fire do nothing.

Specified by:
isFireFunctional in interface Executable
Returns:
true.

isStrict

public boolean isStrict()
Return false.

Specified by:
isStrict in interface Executable
Returns:
false.

iterate

public int iterate(int count)
            throws IllegalActionException
Do nothing and return 0.

Specified by:
iterate in interface Executable
Parameters:
count - The number of iteration.
Returns:
0
Throws:
IllegalActionException - Not thrown in this class.

labelSet

public java.util.Set<java.lang.String> labelSet()
Return the set of names of ingredients contained in this entity that can be resolved.

Specified by:
labelSet in interface GTEntity
Returns:
The set of names.

match

public boolean match(NamedObj object)
Return true if the given object is an instance of State (either the one in the deprecated FSM domain or the one in modal model since Ptolemy 8.0).

Specified by:
match in interface GTEntity
Parameters:
object - The object to be tested.
Returns:
true if the object is an instance of State.

newReceiver

public Receiver newReceiver()
                     throws IllegalActionException
Return null.

Specified by:
newReceiver in interface Actor
Returns:
null.
Throws:
IllegalActionException - Not thrown in this class.

outputPortList

public java.util.List<?> outputPortList()
Return an empty list.

Specified by:
outputPortList in interface Actor
Returns:
An empty list.

postfire

public boolean postfire()
                 throws IllegalActionException
Do nothing and return false.

Specified by:
postfire in interface Executable
Returns:
false
Throws:
IllegalActionException - Not thrown in this class.

prefire

public boolean prefire()
                throws IllegalActionException
Do nothing and return false.

Specified by:
prefire in interface Executable
Returns:
false
Throws:
IllegalActionException - Not thrown in this class.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Do nothing.

Specified by:
preinitialize in interface Initializable
Throws:
IllegalActionException - Not thrown in this class.

removeInitializable

public void removeInitializable(Initializable initializable)
Do nothing.

Specified by:
removeInitializable in interface Initializable
Parameters:
initializable - The initializable.
See Also:
Initializable.addInitializable(Initializable)

setContainer

public void setContainer(CompositeEntity container)
                  throws IllegalActionException,
                         NameDuplicationException
Specify the container, adding the entity to the list of entities in the container. If the container already contains an entity with the same name, then throw an exception and do not make any changes. Similarly, if the container is not in the same workspace as this entity, throw an exception. If this entity is a class element and the proposed container does not match the current container, then also throw an exception. If the entity is already contained by the container, do nothing. If this entity already has a container, remove it from that container first. Otherwise, remove it from the directory of the workspace, if it is present. If the argument is null, then unlink the ports of the entity from any relations and remove it from its container. It is not added to the workspace directory, so this could result in this entity being garbage collected. Derived classes may further constrain the container to subclasses of CompositeEntity by overriding the protected method _checkContainer(). This method validates all deeply contained instances of Settable, since they may no longer be valid in the new context. This method is write-synchronized to the workspace and increments its version number.

Overrides:
setContainer in class ComponentEntity
Parameters:
container - The proposed container.
Throws:
IllegalActionException - If the action would result in a recursive containment structure, or if this entity and container are not in the same workspace, or if the protected method _checkContainer() throws it, or if a contained Settable becomes invalid and the error handler throws it.
NameDuplicationException - If the name of this entity collides with a name already in the container.
See Also:
ComponentEntity.getContainer()

stop

public void stop()
Do nothing.

Specified by:
stop in interface Executable

stopFire

public void stopFire()
Do nothing.

Specified by:
stopFire in interface Executable

terminate

public void terminate()
Do nothing.

Specified by:
terminate in interface Executable

typeConstraints

public java.util.Set<Inequality> typeConstraints()
                                          throws IllegalActionException
Return an empty list.

Specified by:
typeConstraints in interface TypedActor
Returns:
An empty list.
Throws:
IllegalActionException - Not thrown in this class.
See Also:
Inequality

updateAppearance

public void updateAppearance(GTIngredientsAttribute attribute)
Update appearance of this entity.

Specified by:
updateAppearance in interface GTEntity
Parameters:
attribute - The attribute containing ingredients of this entity.
See Also:
GTEntityUtils.updateAppearance(GTEntity, GTIngredientsAttribute)

valueChanged

public void valueChanged(Settable settable)
React to the fact that the specified Settable has changed.

Specified by:
valueChanged in interface ValueListener
Parameters:
settable - The object that has changed value.
See Also:
GTEntityUtils.valueChanged(GTEntity, Settable)

wrapup

public void wrapup()
            throws IllegalActionException
Do nothing.

Specified by:
wrapup in interface Initializable
Throws:
IllegalActionException - Not thrown in this class.