dol: initial dol commit
[jump.git] / dol / src / dol / visitor / yapi / YapiVisitor.java
1 /* $Id: YapiVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.visitor.yapi;
3
4 import java.io.File;
5 import java.io.FileNotFoundException;
6 import java.io.IOException;
7
8 import dol.datamodel.pn.ProcessNetwork;
9 import dol.util.Copier;
10 import dol.visitor.PNVisitor;
11
12 /**
13  *
14  */
15 public class YapiVisitor extends PNVisitor {
16
17     /**
18      * Constructor.
19      */
20     public YapiVisitor(String packageName) {
21         _packageName = packageName;
22     }
23
24     /**
25      *
26      */
27     public void visitComponent(ProcessNetwork pn) {
28         try {
29             _generateDirHierarchy();
30
31             pn.accept(new YapiMakefileVisitor(_srcDir));
32             pn.accept(new YapiModuleVisitor(_srcDir));
33             pn.accept(new YapiProcessVisitor(_wrapperDir));
34
35         } catch (Exception e) {
36             System.out.println(" SystemC PN Visitor: exception " +
37                                "occured: " + e.getMessage());
38             e.printStackTrace();
39         }
40     }
41
42     /**
43      *
44      */
45     private void _generateDirHierarchy()
46         throws IOException, FileNotFoundException {
47
48         File dir = new File(_packageName);
49         dir.mkdirs();
50
51         _srcDir = _packageName + _delimiter + _srcDirName;
52         dir = new File(_srcDir);
53         dir.mkdirs();
54
55         _libDir = _srcDir + _delimiter + _libDirName;
56         dir = new File(_libDir);
57         dir.mkdirs();
58
59         _processDir = _srcDir + _delimiter + _processDirName;
60         dir = new File(_processDir);
61         dir.mkdirs();
62
63         _wrapperDir = _srcDir + _delimiter + _wrapperDirName;
64         dir = new File(_wrapperDir);
65         dir.mkdirs();
66
67         // copy library
68         String libraryPath = _ui.getMySystemCLib();
69         libraryPath = libraryPath.replaceAll("systemC",
70                 "yapi");
71         File source = new File(libraryPath);
72         File destination = new File(_libDir);
73         new Copier().copy(source, destination);
74
75         //copy process src code
76         source = new File(_srcDirName);
77         destination = new File(_processDir);
78         new Copier().copy(source, destination);
79     }
80
81     protected String _packageName = null;
82
83     protected String _srcDir = "";
84     protected static String _srcDirName = "src";
85
86     protected String _libDir = "";
87     protected static String _libDirName = "lib";
88
89     protected String _processDir = "";
90     protected static String _processDirName = "processes";
91
92     protected String _wrapperDir = "";
93     protected static String _wrapperDirName = "wrappers";
94 }
95