ptolemy.actor.util
Class FunctionDependency

java.lang.Object
  extended byptolemy.actor.util.FunctionDependency
Direct Known Subclasses:
FunctionDependencyOfAtomicActor, FunctionDependencyOfCompositeActor, FunctionDependencyOfFSMActor

public abstract class FunctionDependency
extends java.lang.Object

A FunctionDependency is an abstract class that describes the function dependency that output ports of an associated actor have on its input ports. The associated actor is specified by the constructor argument and cannot be changed once this object is constructed.

An output port has a function dependency on an input port if in its fire method, it sends tokens on the output port that depend on tokens gotten from the input port.

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.1.2.3 2004/06/20 03:10:43 cxh Exp $
Author:
Haiyang Zheng
Accepted Rating:
Green (eal)
Proposed Rating:
Green (hyzheng)

Field Summary
protected  DirectedGraph _dependencyGraph
          The dependency graph of the associated actor.
 
Constructor Summary
FunctionDependency(Actor actor)
          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.
 Actor getActor()
          Get the associated actor.
 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.Set getInputPortsDependentOn(IOPort outputPort)
          Get the input ports on which the given output port is dependent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dependencyGraph

protected DirectedGraph _dependencyGraph
The dependency graph of the associated actor.

Constructor Detail

FunctionDependency

public FunctionDependency(Actor actor)
Construct a FunctionDependency object for the given actor.

Parameters:
actor - The actor.
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.

getActor

public Actor getActor()
Get the associated actor.

Returns:
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.Set getInputPortsDependentOn(IOPort outputPort)
Get the input ports on which the given output port is dependent.

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

_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.


_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()