Skip to content
Snippets Groups Projects
Commit 035cf2e0 authored by Christian Wulf's avatar Christian Wulf
Browse files

worked on draft for Traversor

parent 1206afc2
No related branches found
No related tags found
No related merge requests found
package teetime.framework; package teetime.framework;
import teetime.framework.pipe.IPipe;
public interface StageVisitor { public interface StageVisitor {
public enum VisitorBehavior { public enum VisitorBehavior {
CONTINUE, STOP CONTINUE, STOP
} }
VisitorBehavior visit(Stage stage); VisitorBehavior visit(Stage stage, IPipe inputPipe);
} }
package teetime.framework; package teetime.framework;
import java.util.HashSet;
import java.util.Set;
import teetime.framework.StageVisitor.VisitorBehavior; import teetime.framework.StageVisitor.VisitorBehavior;
import teetime.framework.pipe.IPipe; import teetime.framework.pipe.IPipe;
public class Traversor { public class Traversor {
private final StageVisitor stageVisitor; private final StageVisitor stageVisitor;
private final Set<Stage> visitedStage = new HashSet<Stage>();
public Traversor(final StageVisitor stageVisitor) { public Traversor(final StageVisitor stageVisitor) {
this.stageVisitor = stageVisitor; this.stageVisitor = stageVisitor;
} }
public void traverse(final Stage stage) { public void traverse(final Stage stage, final IPipe inputPipe) {
VisitorBehavior visitorBehavior = stageVisitor.visit(stage); if (!visitedStage.contains(stage)) {
visitedStage.add(stage);
} else {
return;
}
VisitorBehavior visitorBehavior = stageVisitor.visit(stage, inputPipe);
if (visitorBehavior == VisitorBehavior.STOP) { if (visitorBehavior == VisitorBehavior.STOP) {
return; return;
} }
...@@ -22,7 +32,7 @@ public class Traversor { ...@@ -22,7 +32,7 @@ public class Traversor {
IPipe pipe = outputPort.getPipe(); IPipe pipe = outputPort.getPipe();
if (null != pipe) { if (null != pipe) {
Stage owningStage = pipe.getTargetPort().getOwningStage(); Stage owningStage = pipe.getTargetPort().getOwningStage();
traverse(owningStage); // recursive call traverse(owningStage, pipe); // recursive call
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment