mapss.dif
Class DIFHierarchy

java.lang.Object
  extended by mapss.dif.graph.hierarchy.Hierarchy
      extended by mapss.dif.DIFHierarchy
Direct Known Subclasses:
PSDFSpecification

public class DIFHierarchy
extends Hierarchy

DIFHierarchy class. DIFHierarchy class extends Hierarchy. It overrides the methods in Hierarchy to limit the associated graph to be DIFGraph. It also overrides mirror(boolean) to mirror a DIFHierarchy including all graph topologies, interface ports, element weights, DIFAttributes, and DIFParameters.

Ports in DIFHierarchy can have attributes like edges and nodes in DIFGraph. Ports cannot contain weights because they are not elements in graphs. The DIFHierarchy provides the AttributeContainer to store the attributes of Ports.

DIF utilizes edge weights to record the production rate and consumption rate of the source node and sink node of that edge. No edge will be built between a nod and its associated port. In this situation, DIF specifies the production rate and consumption rate as port attributes. Therefore, "production" and "consumption" attributes are reserved for ports in this purpose. Because ports do not have weights to further distinguish between different types of weights (ex: CSDF, BCSDF, SDF, HSDF), users need to be very careful about assigning the "production" and "consumption" attributes. The specific data type for the production and consumption rate of each dataflow model can be found in xxxEdgeWeight. xxxLanguageAnalysis will also take the responsibility to check the production and consumption rate for edges and ports.

Override method Hierarchy.flatten(Node) to support DIFAttribute references problem after flatten and update production and consumption attributes of ports to the flattened edges.

mirror() method can completely clone/mirror the DIFHierarchy/DIFGraph.

Version:
$Id: DIFHierarchy.java 409 2007-05-13 19:47:16Z plishker $
Author:
Chia-Jui Hsu, Fuat Keceli, Shuvra S. Bhattacharyya, Ming-Yung Ko
See Also:
Graph, DIFGraph, Hierarchy

Field Summary
 
Fields inherited from class mapss.dif.graph.hierarchy.Hierarchy
_graph, _hierarchyName, _parent, _ports, _superNodes
 
Constructor Summary
DIFHierarchy(DIFGraph graph)
          Construct a hierarchy object with an empty name.
DIFHierarchy(DIFGraph graph, java.lang.String name)
          Construct a hierarchy object with a name.
 
Method Summary
protected  mocgraph.Edge _copyEdge(mocgraph.Edge edge, mocgraph.Node source, mocgraph.Node sink)
          Returns a copy of the edge with the given source and sink nodes as well as adding the new edge to the underlying graph.
protected  mocgraph.Graph _graphType()
          Returns an empty DIFGraph.
 Hierarchy flatten(mocgraph.Node superNode)
          Override Hierarchy.flatten(Node).
 DIFAttribute getAttribute(Port port, java.lang.String name)
          Returns the DIFAttribute associated with port.
 java.util.List getAttributes(Port port)
          Returns a List of DIFAttribute associated with port.
 DIFHierarchy mirror()
          Completely mirror/clone this hierarchy, sub-hierarchies, graphs, attributes, and parameters.
 Hierarchy mirror(boolean cloneWeights)
          Override Hierarchy.mirror(boolean) to restrict to always clone weights.
 DIFHierarchy mirror(java.util.Map mirrorMap)
          Mirror/clone this hierarchy, sub-hierarchies, graphs, attributes, and parameters based on the given mirrorMap
 void setAttribute(Port port, DIFAttribute attribute)
          Sets an attribute of a Port.
 
Methods inherited from class mapss.dif.graph.hierarchy.Hierarchy
_mirrorGraph, _putSuperNode, _removeSuperNode, addSuperNode, deepFlatten, deepPurge, disconnect, disconnectSuperNode, flatten, getGraph, getName, getParent, getPorts, getSuperNodes, hierarchyGraph, isDirected, purge, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DIFHierarchy

public DIFHierarchy(DIFGraph graph)
Construct a hierarchy object with an empty name.

Parameters:
graph - The graph object that backs the hierarchy.

DIFHierarchy

public DIFHierarchy(DIFGraph graph,
                    java.lang.String name)
Construct a hierarchy object with a name.

Parameters:
graph - The graph object that backs the hierarchy.
name - Name of the hierarchy.
Method Detail

getAttribute

public DIFAttribute getAttribute(Port port,
                                 java.lang.String name)
Returns the DIFAttribute associated with port.

Parameters:
port - A Port in this hierarchy.
name - The name of this DIFAttribute.
Returns:
The DIFAttribute with the given name. Null if the attribute doesn't exist.
Throws:
HierarchyException - If the port is not contained in this hierarchy.
See Also:
DIFAttribute, AttributeContainer

getAttributes

public java.util.List getAttributes(Port port)
Returns a List of DIFAttribute associated with port.

Parameters:
port - A Port in this hierarchy.
Returns:
A List of DIFAttribute associated with port. If there is no AttributeContainer associated with port, it returns null.
Throws:
HierarchyException - If the port is not contained in this hierarchy.
See Also:
AttributeContainer

flatten

public Hierarchy flatten(mocgraph.Node superNode)
Override Hierarchy.flatten(Node). Support set the production and consumption attribute of sub port to the edge in the flattened graph. Also support reset the attribute value that refers to the sub port to the new edge or outer port in the flattened graph.

Note that the original hierarchy is modified and cannot be restored. If superNode is not actually a super node (it is just a normal node), this hierarchy object won't be modified and this method returns null.

Overrides:
flatten in class Hierarchy
Parameters:
superNode - A super node in this hierarchy.
Returns:
A DIFHierarchy object of the cloned version of the original sub-hierarchy.

mirror

public Hierarchy mirror(boolean cloneWeights)
Override Hierarchy.mirror(boolean) to restrict to always clone weights. Note that DIFGraph requires all elements to have proper weights.

Overrides:
mirror in class Hierarchy
Parameters:
cloneWeights - Weights of the nodes and edges will be cloned if true.
Returns:
The mirrored DIFHierarchy.

mirror

public DIFHierarchy mirror()
Completely mirror/clone this hierarchy, sub-hierarchies, graphs, attributes, and parameters.

Returns:
The mirrored DIFHierarchy.

mirror

public DIFHierarchy mirror(java.util.Map mirrorMap)
Mirror/clone this hierarchy, sub-hierarchies, graphs, attributes, and parameters based on the given mirrorMap

Returns:
The mirrored DIFHierarchy.

setAttribute

public void setAttribute(Port port,
                         DIFAttribute attribute)
Sets an attribute of a Port. If there exist another attribute with the same name, the previous value is overridden.

DIF utilizes edge weights to record the production rate and consumption rate of the source node and sink node of that edge. No edge will be built between a nod and its associated port. In this situation, DIF specifies the production rate and consumption rate as port attributes. Therefore, "production" and "consumption" attributes are reserved for ports in this purpose. Because ports do not have weights to further distinguish between different types of weights (ex: CSDF, BCSDF, SDF, HSDF), users need to be very careful about assigning the "production" and "consumption" attributes.

A port cannot have both "production" and "consumption" attributes at the same time. Because Port is directional.

Parameters:
port - A port in this hierarchy.
attribute - A DIFAttribute.
Throws:
HierarchyException - If the port is not contained in this hierarchy.
java.lang.IllegalArgumentException - If the name of attribute is null.

_copyEdge

protected mocgraph.Edge _copyEdge(mocgraph.Edge edge,
                                  mocgraph.Node source,
                                  mocgraph.Node sink)
Description copied from class: Hierarchy
Returns a copy of the edge with the given source and sink nodes as well as adding the new edge to the underlying graph. This function only copies (by reference) the weight of the edge in this implementation. If an extended version uses a different kind of graph, additional information attributed to an edge should be copied too.

Overrides:
_copyEdge in class Hierarchy
Parameters:
edge - Original edge.
source - New source node.
sink - New sink node.
Returns:
The new edge.

_graphType

protected mocgraph.Graph _graphType()
Returns an empty DIFGraph.

Overrides:
_graphType in class Hierarchy
Returns:
An empty DIFGraph.