2010-10-26 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug309042
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / 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
12package org.eclipse.linuxtools.lttng.ui.model.trange;\r
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
24 private String traceID = "";\r
25 private String processType = "User"; // Kernel or user thread\r
26 private Long cpu = 0L;\r
27 private String brand = "";\r
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
137 this.traceID = "";\r
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
171 cpu = 0L;\r
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
189 brand = "";\r
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
225 public String toString() {\r
226 return "[TimeRangeEventProcess:" + super.toString() +\r
227 ",pid=" + pid + ",tgid=" + tgid + ",ppid=" + ppid + ",ctime=" + creationTime +\r
228 ",trace=" + traceID + ",ptype=" + processType + ",cpu=" + cpu + ",brand=" + brand + "]";\r
229 }\r
230\r
6e512b93 231}\r
This page took 0.036923 seconds and 5 git commands to generate.