ptolemy.actor.util
Class FunctionDependency

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.kernel.util.SingletonAttribute
              extended by ptolemy.actor.util.FunctionDependency
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Singleton
Direct Known Subclasses:
FunctionDependencyOfAtomicActor, FunctionDependencyOfCompositeActor, FunctionDependencyOfFSMActor

public abstract class FunctionDependency
extends SingletonAttribute

This is an abstract base class that describes the dependency that data at an output port has on data at an input port in a firing of the container, which is an entity. In particular, an output port does not depend on an input port if the fire() method of the container produces outputs on the output port or asserts that no outputs will be produced on the output port in this iteration without knowing anything about the input port (what data are there, or even whether there are data). The container is specified by the constructor argument and cannot be changed once this object is constructed.

This class uses a graph to describe the function dependency, where the nodes of the graph correspond to the ports and an edge indicates a function dependency. The edges go from input ports to output ports that depend on them.

The dependency graph by default indicates complete dependency, which means that each output port depends on all input ports. This default dependency graph is constructed in the protected method _constructDependencyGraph(), which can be overridden in subclasses to construct a more accurate dependency graph. See FunctionDependencyOfAtomicActor and FunctionDependencyOfCompositeActor for example concrete subclasses. The composite actor version analyzes the contained model to determine from the function dependencies of the contained actors and from the connections what the function dependencies of the composite actor are.

Since:
Ptolemy II 4.0
Version:
$Id: FunctionDependency.java,v 1.22 2007/12/07 06:26:46 cxh Exp $
Author:
Haiyang Zheng
See Also:
Serialized Form
Accepted Rating:
Green (eal)
Proposed Rating:
Green (hyzheng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
protected  DirectedGraph _dependencyGraph
          The dependency graph of the associated actor.
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
FunctionDependency(Entity container)
          Construct a FunctionDependency object for the given actor.
 
Method Summary
protected  DirectedGraph _constructConnectedDependencyGraph()
          Construct a complete dependency graph with all the ports of the associated actor as nodes and edges going from each input port node to each output port node.
protected  void _constructDependencyGraph()
          Construct the dependency graph for the associated actor.
protected  DirectedGraph _constructDisconnectedDependencyGraph()
          Construct and return a dependency graph containing all the ports of the associated actor as nodes and no edges.
protected  void _validate()
          Update the FunctionDependency object.
 DirectedGraph getDependencyGraph()
          Return the dependency graph representing the function dependency of an actor.
 java.util.Set getDependentOutputPorts(IOPort inputPort)
          Get the output ports that depend on the given input port.
 java.util.List getInputPortsDependentOn(IOPort outputPort)
          Get the input ports on which the given output port is dependent.
 void setContainer(NamedObj container)
          Add this attribute to the given container.
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_dependencyGraph

protected DirectedGraph _dependencyGraph
The dependency graph of the associated actor.

Constructor Detail

FunctionDependency

public FunctionDependency(Entity container)
                   throws IllegalActionException,
                          NameDuplicationException
Construct a FunctionDependency object for the given actor. The name of this attribute is always "_functionDependency".

Parameters:
container - The container.
Throws:
IllegalActionException - If the name has a period in it, or the attribute is not compatible with the specified container.
NameDuplicationException - If the container already has an attribute with this name, and the class of that container is not SingletonAttribute.
Method Detail

getDependencyGraph

public DirectedGraph getDependencyGraph()
Return the dependency graph representing the function dependency of an actor. The nodes of the graph are the ports of the actor. Each edge indicates a function dependency between an input port and an output port.

Returns:
A dependency graph for the associated actor.

getDependentOutputPorts

public java.util.Set getDependentOutputPorts(IOPort inputPort)
Get the output ports that depend on the given input port.

Parameters:
inputPort - The given input port.
Returns:
A set of output ports that depend on the input port. The elements of the set are all instances of IOPort.

getInputPortsDependentOn

public java.util.List getInputPortsDependentOn(IOPort outputPort)
Get the input ports on which the given output port is dependent.

Parameters:
outputPort - The given output port.
Returns:
A list of input ports on which the output port is dependent. The elements of the set are all instances of IOPort.

setContainer

public void setContainer(NamedObj container)
                  throws IllegalActionException,
                         NameDuplicationException
Add this attribute to the given container.

Overrides:
setContainer in class SingletonAttribute
Parameters:
container - The container to attach this attribute to.
Throws:
IllegalActionException - If this attribute is not of the expected class for the container, or it has no name, or the attribute and 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 attribute that is of class SingletonConfigurableAttribute.
See Also:
Attribute.getContainer()

_constructConnectedDependencyGraph

protected final DirectedGraph _constructConnectedDependencyGraph()
Construct a complete dependency graph with all the ports of the associated actor as nodes and edges going from each input port node to each output port node. This is provided as a convenience for subclasses that override _constructDependencyGraph() to build a starting point.

Returns:
A complete dependency graph.

_constructDependencyGraph

protected void _constructDependencyGraph()
Construct the dependency graph for the associated actor. This base class provides a complete dependency graph. The subclasses may need to override this implementation. This method should only be called from by the protected method _validate(). It is protected only so that subclasses can override it, not so they can call it.

Throws:
IllegalActionException - Not thrown in this class.

_constructDisconnectedDependencyGraph

protected final DirectedGraph _constructDisconnectedDependencyGraph()
Construct and return a dependency graph containing all the ports of the associated actor as nodes and no edges. This is provided as a convenience for subclasses that override _constructDependencyGraph() to build a starting point.

Returns:
A dependency graph with nodes for ports but no edges.

_validate

protected final void _validate()
Update the FunctionDependency object. If it has not been previously constructed, then construct it. If the topology has been changed since it was last constructed (as indicated by the getVersion() method of the workspace of the associated actor), then reconstruct it. Otherwise, do nothing.

See Also:
Workspace.getVersion()