Add new feature of splitting nodes into Scheduling algorithm and fix some bugs in...
[IRC.git] / Robust / src / Analysis / TaskStateAnalysis / FEdge.java
1 package Analysis.TaskStateAnalysis;
2 import IR.*;
3 import Analysis.TaskStateAnalysis.*;
4 import IR.Tree.*;
5 import IR.Flat.*;
6 import java.util.*;
7 import Util.Edge;
8
9 /* Edge *****************/
10
11 public class FEdge extends Edge {
12
13     private String label;
14     private TaskDescriptor td;
15     private int parameterindex;
16     
17     // jzhou
18     private int executeTime;
19     private Hashtable<ClassDescriptor, NewObjInfo> newObjInfos;
20     
21     public class NewObjInfo {
22         int newRate;
23         int probability;
24         
25         public NewObjInfo() {
26             newRate = 0;
27             probability = 0;
28         }
29         
30         public NewObjInfo(int newRate, int probability) {
31             this.newRate = newRate;
32             this.probability = probability;
33         }
34         
35         public int getNewRate() {
36             return this.newRate;
37         }
38         
39         public void setNewRate(int newRate) {
40             this.newRate = newRate;
41         }
42         
43         public int getProbability() {
44             return this.probability;
45         }
46         
47         public void setProbability(int probability) {
48             this.probability = probability;
49         }
50         
51         public boolean equals(Object o) {
52             if (o instanceof NewObjInfo) {
53                 NewObjInfo e=(NewObjInfo)o;
54                 if (e.newRate == this.newRate &&
55                     e.probability == this.probability) {
56                     return true;
57                 }
58             }
59             return false;
60         }
61     }
62     
63     /** Class Constructor
64      * 
65      */
66     public FEdge(FlagState target, String label, TaskDescriptor td, int parameterindex) {
67         super(target);
68         this.label = label;
69         this.td=td;
70         this.parameterindex=parameterindex;
71         this.executeTime = -1;
72         this.newObjInfos = null;
73     }
74     
75     public String getLabel() {
76         return label;
77     }
78     
79     public int hashCode(){
80         return target.hashCode()^label.hashCode();
81     }
82
83     public TaskDescriptor getTask() {
84         return td;
85     }
86
87     public int getIndex() {
88         return parameterindex;
89     }
90         
91     public boolean equals(Object o) {
92         if (o instanceof FEdge) {
93             FEdge e=(FEdge)o;
94             if (e.label.equals(label)&&
95                 e.target.equals(target)&&
96                 e.source.equals(source) &&
97                 e.td==td&&
98                 e.parameterindex==parameterindex &&
99                 e.executeTime == executeTime) {
100                 if(this.newObjInfos != null) {
101                     if(e.newObjInfos == null) {
102                         return false;
103                     } else if(e.newObjInfos.equals(this.newObjInfos)) {
104                         return true;
105                     }
106                 }
107             }
108         }
109         return false;
110     }
111     
112     public int getExeTime() {
113         return this.executeTime;
114     }
115     
116     public void setExeTime(int eTime) {
117         this.executeTime = eTime;
118     }
119     
120     public Hashtable<ClassDescriptor, NewObjInfo> getNewObjInfoHashtable() {
121         return this.newObjInfos;
122     }
123     
124     public NewObjInfo getNewObjInfo(ClassDescriptor cd) {
125         if(this.newObjInfos == null) {
126             return null;
127         }
128         return this.newObjInfos.get(cd);
129     }
130     
131     public void addNewObjInfo(ClassDescriptor cd, int newRate, int probability) {
132         if(this.newObjInfos == null) {
133             this.newObjInfos = new Hashtable<ClassDescriptor, NewObjInfo>();
134         }
135         this.newObjInfos.put(cd, new NewObjInfo(newRate, probability));
136     }
137 }