diff --git a/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageDecision.java b/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageDecision.java index f6a2e41..b6576d6 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageDecision.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageDecision.java @@ -1,16 +1,30 @@ package algorithm; +import java.util.HashSet; + import models.*; import models.dataFlowModel.*; public class DataStorageDecision { + static private HashSet arrivedNode = new HashSet<>(); + static public void run(ResourceDependencyGraph graph) { - for(Edge e:graph.getEdges()) { - if(((PushPullAttribute) (((ResourceDependency)e).getAttribute())).getOptions().get(0) == PushPullValue.PUSH) { - - }else { - + for (Node n : graph.getNodes()) { + ResourceNode resource = (ResourceNode) n; + trackNode(resource); + } + } + + static private void trackNode(ResourceNode resource) { + if(arrivedNode.contains(resource)) return; + arrivedNode.add(resource); + boolean flag = false; + for (Edge e : resource.getInEdges()) { + if (((PushPullAttribute) e.getAttribute()).getOptions().get(0) == PushPullValue.PUSH) { + trackNode((ResourceNode) e.getSource()); + flag = true; } } + ((StoreAttribute) resource.getAttribute()).setStored(flag); } }