dol: initial dol commit
[jump.git] / dol / src / dol / visitor / rtems / RtemsShaperVisitor.java
diff --git a/dol/src/dol/visitor/rtems/RtemsShaperVisitor.java b/dol/src/dol/visitor/rtems/RtemsShaperVisitor.java
new file mode 100644 (file)
index 0000000..cd50166
--- /dev/null
@@ -0,0 +1,50 @@
+/* $Id: RtemsShaperVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.visitor.rtems;
+
+import java.util.HashMap;
+
+import dol.datamodel.pn.Process;
+import dol.datamodel.pn.ProcessNetwork;
+import dol.util.Sed;
+import dol.visitor.PNVisitor;
+
+/**
+ * This class is a class for a visitor that is used to generate
+ * a wrapper class for the traffic shaper.
+ */
+public class RtemsShaperVisitor extends PNVisitor {
+
+    /**
+     * Constructor.
+     *
+     * @param dir target directory
+     */
+    public RtemsShaperVisitor(String dir, HashMap<Process, Integer> sinkMap) {
+        _dir = dir;
+        _sinkMap = sinkMap;
+    }
+
+    /**
+     *
+     * @param x process network that needs to be processed
+     */
+    public void visitComponent(ProcessNetwork x) {
+        try {
+            String filename = _dir + _delimiter + "traffic_shaping.h";
+
+            Sed sed = new Sed();
+            String tmp = "NUMBER_OF_QUEUES " + x.getChannelList().size();
+            sed.sed(filename, "@NUMBER_OF_QUEUES@", tmp);
+            tmp = "NUMBER_OF_SINKS " + _sinkMap.size();
+            sed.sed(filename, "@NUMBER_OF_SINKS@", tmp);
+        }
+        catch (Exception e) {
+            System.out.println("RtemsProcessVisitor: exception "
+                    + "occured: " + e.getMessage());
+            e.printStackTrace();
+        }
+    }
+
+    protected String _dir = null;
+    protected HashMap<Process, Integer> _sinkMap;
+}