X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2FHdsdVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2FHdsdVisitor.java;h=56421b88b931b6c946461212b00ce0ab74ec3567;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/HdsdVisitor.java b/dol/src/dol/visitor/hdsd/HdsdVisitor.java new file mode 100644 index 0000000..56421b8 --- /dev/null +++ b/dol/src/dol/visitor/hdsd/HdsdVisitor.java @@ -0,0 +1,113 @@ +package dol.visitor.hdsd; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import dol.datamodel.mapping.Mapping; +import dol.util.CodePrintStream; +import dol.util.Copier; +import dol.visitor.MapVisitor; + +/** + * This class is a class for a visitor that is used to generate + * a HdS package with distributed simulation support. + */ +public class HdsdVisitor extends MapVisitor { + + /** + * Constructor. + * + * @param packageName name of the HdSd directory + */ + public HdsdVisitor(String packageName) { + _packageName = packageName; + } + + /** + * + * @param x mapping that needs to be rendered. + */ + public void visitComponent(Mapping x) { + try { + _generateDirHierarchy(); + + x.accept(new HdsdMakefileVisitor(_srcDir)); + x.accept(new HdsdModuleVisitor(_srcDir)); + x.getPN().accept(new HdsdProcessVisitor(_wrapperDir)); + x.accept(new HdsdScriptVisitor(_srcDir)); + } + catch (Exception e) { + System.out.println("HdSdVisitor: exception occured: " + + e.getMessage()); + e.printStackTrace(); + } + } + + /** + * + */ + protected void _generateDirHierarchy() + throws IOException, FileNotFoundException { + File dir = new File(_packageName); + dir.mkdirs(); + + _srcDir = _packageName + "/" + _srcDirName; + dir = new File(_srcDir); + dir.mkdirs(); + + _libDir = _srcDir + "/" + _libDirName; + dir = new File(_libDir); + dir.mkdirs(); + + _scdDir = _srcDir + "/" + _scdDirName; + dir = new File(_scdDir); + dir.mkdirs(); + + _processDir = _srcDir + "/" + _processDirName; + dir = new File(_processDir); + dir.mkdirs(); + + _wrapperDir = _srcDir + "/" + _wrapperDirName; + dir = new File(_wrapperDir); + dir.mkdirs(); + + //copy library files + String sdir = _ui.getVisitorDir() + "hdsd" + "/" + "lib"; + File source = new File(sdir); + File destination = new File(_libDir); + new Copier().copy(source, destination); + + // copy scd library files + sdir = _ui.getVisitorDir() + "hdsd" + "/" + "scd"; + source = new File(sdir); + destination = new File(_scdDir); + new Copier().copy(source, destination); + + //copy process source code + source = new File(_srcDirName); + destination = new File(_processDir); + new Copier().copy(source, destination); + } + + protected String _packageName = null; + + protected String _srcDir = ""; + protected static String _srcDirName = "src"; + + protected String _libDir = ""; + protected static String _libDirName = "lib"; + + protected String _scdDir = ""; + protected static String _scdDirName = "scd"; + + protected String _processDir = ""; + protected static String _processDirName = "processes"; + + protected String _wrapperDir = ""; + protected static String _wrapperDirName = "sc_wrappers"; + + protected String _threadPostfix = "_thread"; + + protected CodePrintStream _mainPS = null; +}