Skip to main content
summaryrefslogtreecommitdiffstats
blob: 82c12dc839b4d35d2004eb63eb1856d333866a14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*******************************************************************************
 * Copyright (c) 2009 Ericsson
 * 
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
 *******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.model.trange;

public class TimeRangeEventProcess extends TimeRangeComposite implements
		Comparable<TimeRangeEventProcess> {
	// ========================================================================
	// Data
	// =======================================================================
	// GUI information
	private Long pid = 0L;
	private Long tgid = 0L;
	private Long ppid = 0L;
	private Long creationTime = 0L;
	private String traceID = "";
	private String processType = "User"; // Kernel or user thread
	private Long cpu = 0L;
	private String brand = "";

	// ========================================================================
	// Constructor
	// =======================================================================
	/**
	 * @param id
	 * @param name
	 * @param sTime
	 *            normally set to the Trace start time
	 * @param stopTime
	 *            normally set to the Trace end time
	 * @param groupName
	 * @param className
	 */
	public TimeRangeEventProcess(int id, String name, long startTime,
			long stopTime, String groupName, String className, Long cpu,
			long insertionTime) {

		super(id, startTime, stopTime, name, CompositeType.PROCESS,
				insertionTime);
		this.cpu = cpu;
	}

	// ========================================================================
	// Methods
	// =======================================================================
	
	
	/**
     * Interface to add children to this process
     * 
     * @param newEvent
     */
    public void addChildren(TimeRangeEvent newEvent) {
        if ((newEvent != null)) {
            this.ChildEventLeafs.add(newEvent);
        }
    }
	
	/**
	 * @return
	 */
	public Long getPid() {
		return pid;
	}

	/**
	 * @param pid
	 */
	public void setPid(Long pid) {
		this.pid = pid;
	}

	/**
	 * @return
	 */
	public Long getTgid() {
		return tgid;
	}

	/**
	 * @param tgid
	 */
	public void setTgid(Long tgid) {
		this.tgid = tgid;
	}

	/**
	 * @return
	 */
	public Long getPpid() {
		return ppid;
	}

	/**
	 * @param ppid
	 */
	public void setPpid(Long ppid) {
		this.ppid = ppid;
	}

	/**
	 * @return
	 */
	public Long getCreationTime() {
		return creationTime;
	}

	/**
	 * @param creationTime
	 */
	public void setCreationTime(Long creationTime) {
		this.creationTime = creationTime;
	}

	/**
	 * @return
	 */
	public String getTraceID() {
		return traceID;
	}

	/**
	 * @param traceID
	 */
	public void setTraceID(String traceID) {
		if (traceID != null) {
			this.traceID = traceID;
		} else {
			this.traceID = "";
		}
	}

	/**
	 * @return
	 */
	public String getProcessType() {
		return processType;
	}

	/**
	 * @param processType
	 */
	public void setProcessType(String processType) {
		if (processType != null) {
			this.processType = processType;
		}
	}

	/**
	 * @return
	 */
	public Long getCpu() {
		return cpu;
	}

	/**
	 * @param cpu
	 */
	public void setCpu(Long cpu) {
		if (cpu != null) {
			this.cpu = cpu;
		} else {
			cpu = 0L;
		}
	}

	/**
	 * @return
	 */
	public String getBrand() {
        return brand;
    }

	/**
	 * @param brand
	 */
    public void setBrand(String brand) {
        if (brand != null) {
            this.brand = brand;
        } else {
            brand = "";
        }
    }
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(TimeRangeEventProcess process) {
		if (process != null) {
			int result = 0;
			// first compare by pid
			Long anotherPid = process.getPid();
			result = pid.compareTo(anotherPid);
			if (result != 0) {
				return result;
			}

			// Then by CPU
			Long anotherCpu = process.getCpu();
			result = cpu.compareTo(anotherCpu);
			if (result != 0) {
				return result;
			}

			// finally by trace
			String anotherTraceId = process.getTraceID();
			return traceID.compareTo(anotherTraceId);
		}

		return 0;
	}
	
    @Override
    public String toString() {
		return "[TimeRangeEventProcess:" + super.toString() +
		",pid=" + pid + ",tgid=" + tgid + ",ppid=" + ppid + ",ctime=" + creationTime +
		",trace=" + traceID + ",ptype=" + processType + ",cpu=" + cpu + ",brand=" + brand + "]";
    }

}

Back to the top