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
.lttng
.ui
.model
.trange
;
14 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngTraceState
;
20 public abstract class TimeRangeEventResource
extends TimeRangeComposite
22 Comparable
<TimeRangeEventResource
> {
24 // ========================================================================
26 // =======================================================================
27 public static enum ResourceTypes
{
28 UNKNOWN
, IRQ
, TRAP
, SOFT_IRQ
, BDEV
, CPU
31 private ResourceTypes type
= ResourceTypes
.UNKNOWN
;
32 private Long resourceId
= null;
34 // ========================================================================
36 // =======================================================================
40 * @param newId Id used by the UI
41 * @param newStartTime normally set to the Trace start time
42 * @param newStopTime normally set to the Trace end time
43 * @param newName the name of this resource
44 * @param newGroupName the group name of this resource. Should be same as the traceId
45 * @param newClassName the classname of this resource.
46 * @param newType the type of the resource, as defined in the ResourceTypes enum
47 * @param newResourceId the resourceId, unique id identifying this resource
50 public TimeRangeEventResource(int newId
, long newStartTime
,
51 long newStopTime
, String newName
, String newGroupName
,
52 String newClassName
, ResourceTypes newType
, Long newResourceId
,
55 super(newId
, newStartTime
, newStopTime
, newName
, newGroupName
,
56 newClassName
, CompositeType
.RESOURCE
, insertionTime
);
59 resourceId
= newResourceId
;
62 // ========================================================================
64 // =======================================================================
67 * Interface to add children to this resource
71 public void addChildren(TimeRangeEvent newEvent
) {
72 if ((newEvent
!= null)) {
73 this.ChildEventLeafs
.add(newEvent
);
80 public Long
getResourceId() {
87 public void setResourceId(Long newResId
) {
88 this.resourceId
= newResId
;
94 public ResourceTypes
getType() {
101 public void setType(ResourceTypes type
) {
106 * Getter for traceId.<br>
107 * Note : traceId and groupName are the same for EventResource
111 public String
getTraceId() {
116 * Getter for traceId.<br>
117 * Note : traceId and groupName are the same for EventResource
121 public void setTraceId(String traceId
) {
122 this.groupName
= traceId
;
129 * @see java.lang.Object#toString()
132 // public String toString() {
133 // return getResourceId().toString() + ":" + getTraceId().toString() + ":"
134 // + getType().toString();
138 @SuppressWarnings("nls")
139 public String
toString() {
140 return "[TimeRangeEventResource: " + super.toString() +
141 ",type=" + type
+ ",resourceId=" + resourceId
+ "]";
145 * Compare function to implement Comparable<br>
147 * Compare by traceId THEN IF EQUAL by resourceType THEN IF EQUAL by
150 * @param comparedResource
151 * The resource to compare to
153 * @return int 0 if equals, negative number if "smaller", positive if
158 public int compareTo(TimeRangeEventResource comparedResource
) {
159 int returnedValue
= 0;
161 if (comparedResource
!= null) {
162 // Compare by trace id first
163 returnedValue
= this.getTraceId().compareTo(
164 comparedResource
.getTraceId());
166 // If same, compare by resourceName
167 if (returnedValue
== 0) {
168 returnedValue
= this.getName().compareTo(
169 comparedResource
.getName());
171 // Finally, if same, compare by ResourceId
172 if (returnedValue
== 0) {
173 returnedValue
= this.getResourceId().compareTo(
174 comparedResource
.getResourceId());
180 return returnedValue
;
183 public abstract String
getStateMode(LttngTraceState traceState
);