Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / model / trange / TimeRangeEventResource.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
6c13869b 14import org.eclipse.linuxtools.lttng.core.state.model.LttngTraceState;\r
6e512b93
ASL
15\r
16/**\r
17 * @author alvaro\r
18 * \r
19 */\r
20public abstract class TimeRangeEventResource extends TimeRangeComposite\r
21 implements\r
22 Comparable<TimeRangeEventResource> {\r
23\r
24 // ========================================================================\r
25 // Data\r
26 // =======================================================================\r
27 public static enum ResourceTypes {\r
28 UNKNOWN, IRQ, TRAP, SOFT_IRQ, BDEV, CPU\r
29 }\r
30\r
31 private ResourceTypes type = ResourceTypes.UNKNOWN;\r
32 private Long resourceId = null;\r
33\r
34 // ========================================================================\r
35 // Constructor\r
36 // =======================================================================\r
37 /**\r
38 * Constructor<br>\r
39 * \r
40 * @param newId Id used by the UI\r
41 * @param newStartTime normally set to the Trace start time\r
42 * @param newStopTime normally set to the Trace end time\r
43 * @param newName the name of this resource\r
44 * @param newGroupName the group name of this resource. Should be same as the traceId\r
45 * @param newClassName the classname of this resource.\r
46 * @param newType the type of the resource, as defined in the ResourceTypes enum\r
47 * @param newResourceId the resourceId, unique id identifying this resource \r
48 * \r
49 */\r
50 public TimeRangeEventResource(int newId, long newStartTime,\r
51 long newStopTime, String newName, String newGroupName,\r
63eecb47
FC
52 String newClassName, ResourceTypes newType, Long newResourceId,\r
53 long insertionTime) {\r
6e512b93
ASL
54\r
55 super(newId, newStartTime, newStopTime, newName, newGroupName,\r
63eecb47 56 newClassName, CompositeType.RESOURCE, insertionTime);\r
6e512b93
ASL
57\r
58 type = newType;\r
59 resourceId = newResourceId;\r
60 }\r
61\r
62 // ========================================================================\r
63 // Methods\r
64 // =======================================================================\r
65\r
66 /**\r
67 * Interface to add children to this resource\r
68 * \r
69 * @param newEvent\r
70 */\r
71 public void addChildren(TimeRangeEvent newEvent) {\r
72 if ((newEvent != null)) {\r
73 this.ChildEventLeafs.add(newEvent);\r
74 }\r
75 }\r
76\r
77 /**\r
78 * @return\r
79 */\r
80 public Long getResourceId() {\r
81 return resourceId;\r
82 }\r
83\r
84 /**\r
85 * @param newResId\r
86 */\r
87 public void setResourceId(Long newResId) {\r
88 this.resourceId = newResId;\r
89 }\r
90\r
91 /**\r
92 * @return\r
93 */\r
94 public ResourceTypes getType() {\r
95 return type;\r
96 }\r
97\r
98 /**\r
99 * @param type\r
100 */\r
101 public void setType(ResourceTypes type) {\r
102 this.type = type;\r
103 }\r
104\r
105 /**\r
106 * Getter for traceId.<br>\r
107 * Note : traceId and groupName are the same for EventResource\r
108 * \r
109 * @return String\r
110 */\r
111 public String getTraceId() {\r
112 return groupName;\r
113 }\r
114\r
115 /**\r
116 * Getter for traceId.<br>\r
117 * Note : traceId and groupName are the same for EventResource\r
118 * \r
119 * @return String\r
120 */\r
121 public void setTraceId(String traceId) {\r
122 this.groupName = traceId;\r
123 }\r
124\r
125 // @Override\r
126 /*\r
127 * (non-Javadoc)\r
128 * \r
129 * @see java.lang.Object#toString()\r
130 */\r
0c2a2e08
FC
131// @Override\r
132// public String toString() {\r
133// return getResourceId().toString() + ":" + getTraceId().toString() + ":"\r
134// + getType().toString();\r
135// }\r
136\r
137 @Override\r
9c4eb5f7 138 @SuppressWarnings("nls")\r
0c2a2e08
FC
139 public String toString() {\r
140 return "[TimeRangeEventResource: " + super.toString() +\r
141 ",type=" + type + ",resourceId=" + resourceId + "]";\r
142 }\r
143\r
144 /**\r
6e512b93
ASL
145 * Compare function to implement Comparable<br>\r
146 * <br>\r
147 * Compare by traceId THEN IF EQUAL by resourceType THEN IF EQUAL by\r
148 * resourceId\r
149 * \r
150 * @param comparedResource\r
151 * The resource to compare to\r
152 * \r
153 * @return int 0 if equals, negative number if "smaller", positive if\r
154 * "bigger".\r
155 */\r
156 // @Override\r
d4011df2 157 @Override\r
6e512b93
ASL
158 public int compareTo(TimeRangeEventResource comparedResource) {\r
159 int returnedValue = 0;\r
160\r
161 if (comparedResource != null) {\r
162 // Compare by trace id first\r
163 returnedValue = this.getTraceId().compareTo(\r
164 comparedResource.getTraceId());\r
165\r
166 // If same, compare by resourceName\r
167 if (returnedValue == 0) {\r
168 returnedValue = this.getName().compareTo(\r
169 comparedResource.getName());\r
170\r
171 // Finally, if same, compare by ResourceId\r
172 if (returnedValue == 0) {\r
173 returnedValue = this.getResourceId().compareTo(\r
174 comparedResource.getResourceId());\r
175 }\r
176 }\r
177\r
178 }\r
179\r
180 return returnedValue;\r
181 }\r
182\r
183 public abstract String getStateMode(LttngTraceState traceState);\r
184}\r
This page took 0.038158 seconds and 5 git commands to generate.