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