modhelxs.util
Class BlockStructureNavHelper

java.lang.Object
  extended by modhelxs.util.BlockStructureNavHelper

public class BlockStructureNavHelper
extends java.lang.Object

A navigation helper for walking block structures.

Author:
boulange

Field Summary
private  java.util.Map<Block,java.util.Set<Block>> block_predecessors_
          Map from blocks to their predecessors (blocks with a pin which is the origin of a relation to a pin of the block).
private  java.util.Map<Block,java.util.Set<Block>> block_successors_
          Map from blocks to their successors (blocks with a pin which is the target of a relation from a pin of the block).
private  java.util.Map<Block,java.util.Set<Block>> filtered_block_predecessors_
          Map from blocks to their predecessors, with some relations filtered out.
private  java.util.Map<Block,java.util.Set<Block>> filtered_block_successors_
          Map from blocks to their successors, with some relations filtered out.
private  java.util.Set<Relation> filtered_internal_relations_
          Set of internal relations, with some relations filtered out
private  java.util.Set<Relation> input_relations_
          Set of input relations (relations from pins of the model to pins of the blocks)
private  java.util.Set<Relation> internal_relations_
          Set of internal relations (relations between pins that do not belong to the model)
private  java.util.Set<Relation> output_relations_
          Set of output relations (relations from pins of the blocks to pins of the model)
private  java.util.Map<Pin,java.util.Set<Pin>> pin_predecessors_
          Map from pins to their predecessors.
private  java.util.Map<Pin,java.util.Set<Pin>> pin_successors_
          Map from pins to their successors.
private  BlockStructure structure_
          The structure in which we navigate.
 
Constructor Summary
BlockStructureNavHelper(BlockStructure s, RelationFilter filter)
          Build a new navigation helper for a block structure, filtering out relations according to a filter.
 
Method Summary
static
<U,V> void
addToMapSet(java.util.Map<U,java.util.Set<V>> map, U key, V value)
          Helper function to add a value to a list associate to a key in a map.
 java.util.Collection<Block> getBlockPredecessors(ObservableEntity p)
          Get the predecessors of block b (blocks with a pin which is a predecessor of a pin of b).
 java.util.Collection<Block> getBlockSuccessors(Block b)
          Get the successors of block b (blocks with a pin which is a successor of a pin of b).
 java.util.Collection<Block> getFilteredBlockPredecessors(Block p)
          Get the predecessors of block b, with some relations filtered out.
 java.util.Collection<Block> getFilteredBlockSuccessors(ObservableEntity b)
          Get the successors of block b, with some relations filtered out.
 java.util.Collection<Relation> getFilteredInternalRelations()
          Return internal relations (not involving the model) ignoring those that are filtered out
 java.util.Collection<Relation> getInputRelations()
          Return input relations (relations from pins of the model to pins of the blocks)
 java.util.Collection<Relation> getInternalRelations()
          Return internal relations (not involving the model)
 java.util.Collection<Relation> getOutputRelations()
          Return output relations (relations from pins of the blocks to pins of the model)
 java.util.Collection<Pin> getPinPredecessors(Pin p)
          Get the predecessors of pin p (pins that are the origin of a relation with target p).
 java.util.Collection<Pin> getPinSuccessors(Pin p)
          Get the successors of pin p (pins that are the target of a relation with origin p).
 java.util.List<Block> topoSort()
          Return a list of the blocks of the structure, topologically sorted.
private  void visit(Block b, java.util.Set<Block> visited_blocks, java.util.List<Block> ordered_blocks)
          Visit a block for topological sort.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

structure_

private BlockStructure structure_
The structure in which we navigate.


pin_successors_

private java.util.Map<Pin,java.util.Set<Pin>> pin_successors_
Map from pins to their successors.


pin_predecessors_

private java.util.Map<Pin,java.util.Set<Pin>> pin_predecessors_
Map from pins to their predecessors.


block_successors_

private java.util.Map<Block,java.util.Set<Block>> block_successors_
Map from blocks to their successors (blocks with a pin which is the target of a relation from a pin of the block).


block_predecessors_

private java.util.Map<Block,java.util.Set<Block>> block_predecessors_
Map from blocks to their predecessors (blocks with a pin which is the origin of a relation to a pin of the block).


filtered_block_successors_

private java.util.Map<Block,java.util.Set<Block>> filtered_block_successors_
Map from blocks to their successors, with some relations filtered out.


filtered_block_predecessors_

private java.util.Map<Block,java.util.Set<Block>> filtered_block_predecessors_
Map from blocks to their predecessors, with some relations filtered out.


internal_relations_

private java.util.Set<Relation> internal_relations_
Set of internal relations (relations between pins that do not belong to the model)


filtered_internal_relations_

private java.util.Set<Relation> filtered_internal_relations_
Set of internal relations, with some relations filtered out


input_relations_

private java.util.Set<Relation> input_relations_
Set of input relations (relations from pins of the model to pins of the blocks)


output_relations_

private java.util.Set<Relation> output_relations_
Set of output relations (relations from pins of the blocks to pins of the model)

Constructor Detail

BlockStructureNavHelper

public BlockStructureNavHelper(BlockStructure s,
                               RelationFilter filter)
Build a new navigation helper for a block structure, filtering out relations according to a filter.

Method Detail

getInternalRelations

public java.util.Collection<Relation> getInternalRelations()
Return internal relations (not involving the model)


getInputRelations

public java.util.Collection<Relation> getInputRelations()
Return input relations (relations from pins of the model to pins of the blocks)


getOutputRelations

public java.util.Collection<Relation> getOutputRelations()
Return output relations (relations from pins of the blocks to pins of the model)


getFilteredInternalRelations

public java.util.Collection<Relation> getFilteredInternalRelations()
Return internal relations (not involving the model) ignoring those that are filtered out


addToMapSet

public static <U,V> void addToMapSet(java.util.Map<U,java.util.Set<V>> map,
                                     U key,
                                     V value)
Helper function to add a value to a list associate to a key in a map.


getPinSuccessors

public java.util.Collection<Pin> getPinSuccessors(Pin p)
Get the successors of pin p (pins that are the target of a relation with origin p).


getPinPredecessors

public java.util.Collection<Pin> getPinPredecessors(Pin p)
Get the predecessors of pin p (pins that are the origin of a relation with target p).


getBlockSuccessors

public java.util.Collection<Block> getBlockSuccessors(Block b)
Get the successors of block b (blocks with a pin which is a successor of a pin of b).


getBlockPredecessors

public java.util.Collection<Block> getBlockPredecessors(ObservableEntity p)
Get the predecessors of block b (blocks with a pin which is a predecessor of a pin of b).


getFilteredBlockSuccessors

public java.util.Collection<Block> getFilteredBlockSuccessors(ObservableEntity b)
Get the successors of block b, with some relations filtered out.


getFilteredBlockPredecessors

public java.util.Collection<Block> getFilteredBlockPredecessors(Block p)
Get the predecessors of block b, with some relations filtered out.


topoSort

public java.util.List<Block> topoSort()
Return a list of the blocks of the structure, topologically sorted.


visit

private void visit(Block b,
                   java.util.Set<Block> visited_blocks,
                   java.util.List<Block> ordered_blocks)
Visit a block for topological sort.