1 package dol.visitor.hdsd;
4 import java.io.FileNotFoundException;
5 import java.io.IOException;
7 import dol.datamodel.mapping.Mapping;
8 import dol.util.CodePrintStream;
9 import dol.util.Copier;
10 import dol.visitor.MapVisitor;
13 * This class is a class for a visitor that is used to generate
14 * a HdS package with distributed simulation support.
16 public class HdsdVisitor extends MapVisitor {
21 * @param packageName name of the HdSd directory
23 public HdsdVisitor(String packageName) {
24 _packageName = packageName;
29 * @param x mapping that needs to be rendered.
31 public void visitComponent(Mapping x) {
33 _generateDirHierarchy();
35 x.accept(new HdsdMakefileVisitor(_srcDir));
36 x.accept(new HdsdModuleVisitor(_srcDir));
37 x.getPN().accept(new HdsdProcessVisitor(_wrapperDir));
38 x.accept(new HdsdScriptVisitor(_srcDir));
41 System.out.println("HdSdVisitor: exception occured: "
50 protected void _generateDirHierarchy()
51 throws IOException, FileNotFoundException {
52 File dir = new File(_packageName);
55 _srcDir = _packageName + "/" + _srcDirName;
56 dir = new File(_srcDir);
59 _libDir = _srcDir + "/" + _libDirName;
60 dir = new File(_libDir);
63 _scdDir = _srcDir + "/" + _scdDirName;
64 dir = new File(_scdDir);
67 _processDir = _srcDir + "/" + _processDirName;
68 dir = new File(_processDir);
71 _wrapperDir = _srcDir + "/" + _wrapperDirName;
72 dir = new File(_wrapperDir);
76 String sdir = _ui.getVisitorDir() + "hdsd" + "/" + "lib";
77 File source = new File(sdir);
78 File destination = new File(_libDir);
79 new Copier().copy(source, destination);
81 // copy scd library files
82 sdir = _ui.getVisitorDir() + "hdsd" + "/" + "scd";
83 source = new File(sdir);
84 destination = new File(_scdDir);
85 new Copier().copy(source, destination);
87 //copy process source code
88 source = new File(_srcDirName);
89 destination = new File(_processDir);
90 new Copier().copy(source, destination);
93 protected String _packageName = null;
95 protected String _srcDir = "";
96 protected static String _srcDirName = "src";
98 protected String _libDir = "";
99 protected static String _libDirName = "lib";
101 protected String _scdDir = "";
102 protected static String _scdDirName = "scd";
104 protected String _processDir = "";
105 protected static String _processDirName = "processes";
107 protected String _wrapperDir = "";
108 protected static String _wrapperDirName = "sc_wrappers";
110 protected String _threadPostfix = "_thread";
112 protected CodePrintStream _mainPS = null;