tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / internal / lttng / ui / model / trange / TimeRangeEventProcess.java
CommitLineData
6e512b93
ASL
1/*******************************************************************************\r
2 * Copyright (c) 2009 Ericsson\r
3 * \r
4 * All rights reserved. This program and the accompanying materials are\r
5 * made available under the terms of the Eclipse Public License v1.0 which\r
6 * accompanies this distribution, and is available at\r
7 * http://www.eclipse.org/legal/epl-v10.html\r
8 * \r
9 * Contributors:\r
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation\r
11 *******************************************************************************/\r
638eac44 12package org.eclipse.linuxtools.internal.lttng.ui.model.trange;\r
6e512b93
ASL
13\r
14public class TimeRangeEventProcess extends TimeRangeComposite implements\r
15 Comparable<TimeRangeEventProcess> {\r
16 // ========================================================================\r
17 // Data\r
18 // =======================================================================\r
19 // GUI information\r
20 private Long pid = 0L;\r
21 private Long tgid = 0L;\r
22 private Long ppid = 0L;\r
23 private Long creationTime = 0L;\r
9c4eb5f7
FC
24 private String traceID = ""; //$NON-NLS-1$\r
25 private String processType = "User"; // Kernel or user thread //$NON-NLS-1$\r
6e512b93 26 private Long cpu = 0L;\r
9c4eb5f7 27 private String brand = ""; //$NON-NLS-1$\r
6e512b93
ASL
28\r
29 // ========================================================================\r
30 // Constructor\r
31 // =======================================================================\r
32 /**\r
33 * @param id\r
34 * @param name\r
35 * @param sTime\r
36 * normally set to the Trace start time\r
37 * @param stopTime\r
38 * normally set to the Trace end time\r
39 * @param groupName\r
40 * @param className\r
41 */\r
42 public TimeRangeEventProcess(int id, String name, long startTime,\r
63eecb47
FC
43 long stopTime, String groupName, String className, Long cpu,\r
44 long insertionTime) {\r
6e512b93 45\r
63eecb47
FC
46 super(id, startTime, stopTime, name, CompositeType.PROCESS,\r
47 insertionTime);\r
6e512b93
ASL
48 this.cpu = cpu;\r
49 }\r
50\r
51 // ========================================================================\r
52 // Methods\r
53 // =======================================================================\r
b513223f
FC
54 \r
55 \r
56 /**\r
57 * Interface to add children to this process\r
58 * \r
59 * @param newEvent\r
60 */\r
61 public void addChildren(TimeRangeEvent newEvent) {\r
62 if ((newEvent != null)) {\r
63 this.ChildEventLeafs.add(newEvent);\r
64 }\r
65 }\r
66 \r
6e512b93
ASL
67 /**\r
68 * @return\r
69 */\r
70 public Long getPid() {\r
71 return pid;\r
72 }\r
73\r
74 /**\r
75 * @param pid\r
76 */\r
77 public void setPid(Long pid) {\r
78 this.pid = pid;\r
79 }\r
80\r
81 /**\r
82 * @return\r
83 */\r
84 public Long getTgid() {\r
85 return tgid;\r
86 }\r
87\r
88 /**\r
89 * @param tgid\r
90 */\r
91 public void setTgid(Long tgid) {\r
92 this.tgid = tgid;\r
93 }\r
94\r
95 /**\r
96 * @return\r
97 */\r
98 public Long getPpid() {\r
99 return ppid;\r
100 }\r
101\r
102 /**\r
103 * @param ppid\r
104 */\r
105 public void setPpid(Long ppid) {\r
106 this.ppid = ppid;\r
107 }\r
108\r
109 /**\r
110 * @return\r
111 */\r
112 public Long getCreationTime() {\r
113 return creationTime;\r
114 }\r
115\r
116 /**\r
117 * @param creationTime\r
118 */\r
119 public void setCreationTime(Long creationTime) {\r
120 this.creationTime = creationTime;\r
121 }\r
122\r
123 /**\r
124 * @return\r
125 */\r
126 public String getTraceID() {\r
127 return traceID;\r
128 }\r
129\r
130 /**\r
131 * @param traceID\r
132 */\r
133 public void setTraceID(String traceID) {\r
134 if (traceID != null) {\r
135 this.traceID = traceID;\r
136 } else {\r
9c4eb5f7 137 this.traceID = ""; //$NON-NLS-1$\r
6e512b93
ASL
138 }\r
139 }\r
140\r
141 /**\r
142 * @return\r
143 */\r
144 public String getProcessType() {\r
145 return processType;\r
146 }\r
147\r
148 /**\r
149 * @param processType\r
150 */\r
151 public void setProcessType(String processType) {\r
152 if (processType != null) {\r
153 this.processType = processType;\r
154 }\r
155 }\r
156\r
157 /**\r
158 * @return\r
159 */\r
160 public Long getCpu() {\r
161 return cpu;\r
162 }\r
163\r
164 /**\r
165 * @param cpu\r
166 */\r
167 public void setCpu(Long cpu) {\r
168 if (cpu != null) {\r
169 this.cpu = cpu;\r
170 } else {\r
1cceddbe 171 this.cpu = 0L;\r
6e512b93
ASL
172 }\r
173 }\r
174\r
175 /**\r
176 * @return\r
177 */\r
178 public String getBrand() {\r
179 return brand;\r
180 }\r
181\r
182 /**\r
183 * @param brand\r
184 */\r
185 public void setBrand(String brand) {\r
186 if (brand != null) {\r
187 this.brand = brand;\r
188 } else {\r
9c4eb5f7 189 brand = ""; //$NON-NLS-1$\r
6e512b93
ASL
190 }\r
191 }\r
192 \r
193 /*\r
194 * (non-Javadoc)\r
195 * \r
196 * @see java.lang.Comparable#compareTo(java.lang.Object)\r
197 */\r
d4011df2 198 @Override\r
6e512b93
ASL
199 public int compareTo(TimeRangeEventProcess process) {\r
200 if (process != null) {\r
201 int result = 0;\r
ba1bc132
ASL
202 // first compare by pid\r
203 Long anotherPid = process.getPid();\r
204 result = pid.compareTo(anotherPid);\r
6e512b93
ASL
205 if (result != 0) {\r
206 return result;\r
207 }\r
208\r
209 // Then by CPU\r
210 Long anotherCpu = process.getCpu();\r
211 result = cpu.compareTo(anotherCpu);\r
212 if (result != 0) {\r
213 return result;\r
214 }\r
215\r
ba1bc132
ASL
216 // finally by trace\r
217 String anotherTraceId = process.getTraceID();\r
218 return traceID.compareTo(anotherTraceId);\r
6e512b93
ASL
219 }\r
220\r
221 return 0;\r
222 }\r
0c2a2e08
FC
223 \r
224 @Override\r
9c4eb5f7 225 @SuppressWarnings("nls")\r
0c2a2e08
FC
226 public String toString() {\r
227 return "[TimeRangeEventProcess:" + super.toString() +\r
228 ",pid=" + pid + ",tgid=" + tgid + ",ppid=" + ppid + ",ctime=" + creationTime +\r
229 ",trace=" + traceID + ",ptype=" + processType + ",cpu=" + cpu + ",brand=" + brand + "]";\r
230 }\r
231\r
c6f55e56
FC
232 /* (non-Javadoc)\r
233 * @see java.lang.Object#hashCode()\r
234 */\r
235 @Override\r
236 public int hashCode() {\r
237 final int prime = 31;\r
238 int result = 1;\r
239 result = prime * result + ((brand == null) ? 0 : brand.hashCode());\r
240 result = prime * result + ((cpu == null) ? 0 : cpu.hashCode());\r
241 result = prime * result + ((creationTime == null) ? 0 : creationTime.hashCode());\r
242 result = prime * result + ((pid == null) ? 0 : pid.hashCode());\r
243 result = prime * result + ((ppid == null) ? 0 : ppid.hashCode());\r
244 result = prime * result + ((processType == null) ? 0 : processType.hashCode());\r
245 result = prime * result + ((tgid == null) ? 0 : tgid.hashCode());\r
246 result = prime * result + ((traceID == null) ? 0 : traceID.hashCode());\r
247 return result;\r
248 }\r
249\r
250 /* (non-Javadoc)\r
251 * @see java.lang.Object#equals(java.lang.Object)\r
252 */\r
253 @Override\r
254 public boolean equals(Object obj) {\r
255 if (this == obj) {\r
256 return true;\r
257 }\r
258 if (obj == null) {\r
259 return false;\r
260 }\r
261 if (!(obj instanceof TimeRangeEventProcess)) {\r
262 return false;\r
263 }\r
264 TimeRangeEventProcess other = (TimeRangeEventProcess) obj;\r
265 if (brand == null) {\r
266 if (other.brand != null) {\r
267 return false;\r
268 }\r
269 } else if (!brand.equals(other.brand)) {\r
270 return false;\r
271 }\r
272 if (cpu == null) {\r
273 if (other.cpu != null) {\r
274 return false;\r
275 }\r
276 } else if (!cpu.equals(other.cpu)) {\r
277 return false;\r
278 }\r
279 if (creationTime == null) {\r
280 if (other.creationTime != null) {\r
281 return false;\r
282 }\r
283 } else if (!creationTime.equals(other.creationTime)) {\r
284 return false;\r
285 }\r
286 if (pid == null) {\r
287 if (other.pid != null) {\r
288 return false;\r
289 }\r
290 } else if (!pid.equals(other.pid)) {\r
291 return false;\r
292 }\r
293 if (ppid == null) {\r
294 if (other.ppid != null) {\r
295 return false;\r
296 }\r
297 } else if (!ppid.equals(other.ppid)) {\r
298 return false;\r
299 }\r
300 if (processType == null) {\r
301 if (other.processType != null) {\r
302 return false;\r
303 }\r
304 } else if (!processType.equals(other.processType)) {\r
305 return false;\r
306 }\r
307 if (tgid == null) {\r
308 if (other.tgid != null) {\r
309 return false;\r
310 }\r
311 } else if (!tgid.equals(other.tgid)) {\r
312 return false;\r
313 }\r
314 if (traceID == null) {\r
315 if (other.traceID != null) {\r
316 return false;\r
317 }\r
318 } else if (!traceID.equals(other.traceID)) {\r
319 return false;\r
320 }\r
321 return true;\r
322 }\r
323\r
6e512b93 324}\r
This page took 0.048196 seconds and 5 git commands to generate.