1
/*******************************************************************************
2
* Copyright (c) 2009 Ericsson
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
10
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11
*******************************************************************************/
12
package org.eclipse.linuxtools.internal.lttng.ui.model.trange;
14
public class TimeRangeEventProcess extends TimeRangeComposite implements
15
Comparable<TimeRangeEventProcess> {
16
// ========================================================================
18
// =======================================================================
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$
29
// ========================================================================
31
// =======================================================================
36
* normally set to the Trace start time
38
* normally set to the Trace end time
42
public TimeRangeEventProcess(int id, String name, long startTime,
43
long stopTime, String groupName, String className, Long cpu,
46
super(id, startTime, stopTime, name, CompositeType.PROCESS,
51
// ========================================================================
53
// =======================================================================
57
* Interface to add children to this process
61
public void addChildren(TimeRangeEvent newEvent) {
62
if ((newEvent != null)) {
63
this.ChildEventLeafs.add(newEvent);
70
public Long getPid() {
77
public void setPid(Long pid) {
84
public Long getTgid() {
91
public void setTgid(Long tgid) {
98
public Long getPpid() {
105
public void setPpid(Long ppid) {
112
public Long getCreationTime() {
117
* @param creationTime
119
public void setCreationTime(Long creationTime) {
120
this.creationTime = creationTime;
126
public String getTraceID() {
133
public void setTraceID(String traceID) {
134
if (traceID != null) {
135
this.traceID = traceID;
137
this.traceID = ""; //$NON-NLS-1$
144
public String getProcessType() {
151
public void setProcessType(String processType) {
152
if (processType != null) {
153
this.processType = processType;
160
public Long getCpu() {
167
public void setCpu(Long cpu) {
178
public String getBrand() {
185
public void setBrand(String brand) {
189
brand = ""; //$NON-NLS-1$
196
* @see java.lang.Comparable#compareTo(java.lang.Object)
199
public int compareTo(TimeRangeEventProcess process) {
200
if (process != null) {
202
// first compare by pid
203
Long anotherPid = process.getPid();
204
result = pid.compareTo(anotherPid);
210
Long anotherCpu = process.getCpu();
211
result = cpu.compareTo(anotherCpu);
217
String anotherTraceId = process.getTraceID();
218
return traceID.compareTo(anotherTraceId);
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 + "]";
233
* @see java.lang.Object#hashCode()
236
public int hashCode() {
237
final int prime = 31;
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());
251
* @see java.lang.Object#equals(java.lang.Object)
254
public boolean equals(Object obj) {
261
if (!(obj instanceof TimeRangeEventProcess)) {
264
TimeRangeEventProcess other = (TimeRangeEventProcess) obj;
266
if (other.brand != null) {
269
} else if (!brand.equals(other.brand)) {
273
if (other.cpu != null) {
276
} else if (!cpu.equals(other.cpu)) {
279
if (creationTime == null) {
280
if (other.creationTime != null) {
283
} else if (!creationTime.equals(other.creationTime)) {
287
if (other.pid != null) {
290
} else if (!pid.equals(other.pid)) {
294
if (other.ppid != null) {
297
} else if (!ppid.equals(other.ppid)) {
300
if (processType == null) {
301
if (other.processType != null) {
304
} else if (!processType.equals(other.processType)) {
308
if (other.tgid != null) {
311
} else if (!tgid.equals(other.tgid)) {
314
if (traceID == null) {
315
if (other.traceID != null) {
318
} else if (!traceID.equals(other.traceID)) {