Commit | Line | Data |
---|---|---|
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 | |
12 | package org.eclipse.linuxtools.lttng.ui.model.trange;\r | |
13 | \r | |
14 | public 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 | |
6e512b93 ASL |
54 | /**\r |
55 | * @return\r | |
56 | */\r | |
57 | public Long getPid() {\r | |
58 | return pid;\r | |
59 | }\r | |
60 | \r | |
61 | /**\r | |
62 | * @param pid\r | |
63 | */\r | |
64 | public void setPid(Long pid) {\r | |
65 | this.pid = pid;\r | |
66 | }\r | |
67 | \r | |
68 | /**\r | |
69 | * @return\r | |
70 | */\r | |
71 | public Long getTgid() {\r | |
72 | return tgid;\r | |
73 | }\r | |
74 | \r | |
75 | /**\r | |
76 | * @param tgid\r | |
77 | */\r | |
78 | public void setTgid(Long tgid) {\r | |
79 | this.tgid = tgid;\r | |
80 | }\r | |
81 | \r | |
82 | /**\r | |
83 | * @return\r | |
84 | */\r | |
85 | public Long getPpid() {\r | |
86 | return ppid;\r | |
87 | }\r | |
88 | \r | |
89 | /**\r | |
90 | * @param ppid\r | |
91 | */\r | |
92 | public void setPpid(Long ppid) {\r | |
93 | this.ppid = ppid;\r | |
94 | }\r | |
95 | \r | |
96 | /**\r | |
97 | * @return\r | |
98 | */\r | |
99 | public Long getCreationTime() {\r | |
100 | return creationTime;\r | |
101 | }\r | |
102 | \r | |
103 | /**\r | |
104 | * @param creationTime\r | |
105 | */\r | |
106 | public void setCreationTime(Long creationTime) {\r | |
107 | this.creationTime = creationTime;\r | |
108 | }\r | |
109 | \r | |
110 | /**\r | |
111 | * @return\r | |
112 | */\r | |
113 | public String getTraceID() {\r | |
114 | return traceID;\r | |
115 | }\r | |
116 | \r | |
117 | /**\r | |
118 | * @param traceID\r | |
119 | */\r | |
120 | public void setTraceID(String traceID) {\r | |
121 | if (traceID != null) {\r | |
122 | this.traceID = traceID;\r | |
123 | } else {\r | |
124 | this.traceID = "";\r | |
125 | }\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
129 | * @return\r | |
130 | */\r | |
131 | public String getProcessType() {\r | |
132 | return processType;\r | |
133 | }\r | |
134 | \r | |
135 | /**\r | |
136 | * @param processType\r | |
137 | */\r | |
138 | public void setProcessType(String processType) {\r | |
139 | if (processType != null) {\r | |
140 | this.processType = processType;\r | |
141 | }\r | |
142 | }\r | |
143 | \r | |
144 | /**\r | |
145 | * @return\r | |
146 | */\r | |
147 | public Long getCpu() {\r | |
148 | return cpu;\r | |
149 | }\r | |
150 | \r | |
151 | /**\r | |
152 | * @param cpu\r | |
153 | */\r | |
154 | public void setCpu(Long cpu) {\r | |
155 | if (cpu != null) {\r | |
156 | this.cpu = cpu;\r | |
157 | } else {\r | |
158 | cpu = 0L;\r | |
159 | }\r | |
160 | }\r | |
161 | \r | |
162 | /**\r | |
163 | * @return\r | |
164 | */\r | |
165 | public String getBrand() {\r | |
166 | return brand;\r | |
167 | }\r | |
168 | \r | |
169 | /**\r | |
170 | * @param brand\r | |
171 | */\r | |
172 | public void setBrand(String brand) {\r | |
173 | if (brand != null) {\r | |
174 | this.brand = brand;\r | |
175 | } else {\r | |
176 | brand = "";\r | |
177 | }\r | |
178 | }\r | |
179 | \r | |
180 | /*\r | |
181 | * (non-Javadoc)\r | |
182 | * \r | |
183 | * @see java.lang.Comparable#compareTo(java.lang.Object)\r | |
184 | */\r | |
185 | public int compareTo(TimeRangeEventProcess process) {\r | |
186 | if (process != null) {\r | |
187 | int result = 0;\r | |
188 | // Compare by trace first\r | |
189 | String anotherTraceId = process.getTraceID();\r | |
190 | result = traceID.compareTo(anotherTraceId);\r | |
191 | if (result != 0) {\r | |
192 | return result;\r | |
193 | }\r | |
194 | \r | |
195 | // Then by CPU\r | |
196 | Long anotherCpu = process.getCpu();\r | |
197 | result = cpu.compareTo(anotherCpu);\r | |
198 | if (result != 0) {\r | |
199 | return result;\r | |
200 | }\r | |
201 | \r | |
202 | // finally Compare by pid\r | |
203 | Long anotherPid = process.getPid();\r | |
204 | return pid.compareTo(anotherPid);\r | |
205 | }\r | |
206 | \r | |
207 | return 0;\r | |
208 | }\r | |
209 | }\r |