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
.core
.state
.model
.LttngTraceState
;
21 public abstract class TimeRangeEventResource
extends TimeRangeComposite
23 Comparable
<TimeRangeEventResource
> {
25 // ========================================================================
27 // =======================================================================
28 public static enum ResourceTypes
{
29 UNKNOWN
, IRQ
, TRAP
, SOFT_IRQ
, BDEV
, CPU
32 private ResourceTypes type
= ResourceTypes
.UNKNOWN
;
33 private Long resourceId
= null;
35 // ========================================================================
37 // =======================================================================
41 * @param newId Id used by the UI
42 * @param newStartTime normally set to the Trace start time
43 * @param newStopTime normally set to the Trace end time
44 * @param newName the name of this resource
45 * @param newGroupName the group name of this resource. Should be same as the traceId
46 * @param newClassName the classname of this resource.
47 * @param newType the type of the resource, as defined in the ResourceTypes enum
48 * @param newResourceId the resourceId, unique id identifying this resource
51 public TimeRangeEventResource(int newId
, long newStartTime
,
52 long newStopTime
, String newName
, String newGroupName
,
53 String newClassName
, ResourceTypes newType
, Long newResourceId
,
56 super(newId
, newStartTime
, newStopTime
, newName
, newGroupName
,
57 newClassName
, CompositeType
.RESOURCE
, insertionTime
);
60 resourceId
= newResourceId
;
63 // ========================================================================
65 // =======================================================================
68 * Interface to add children to this resource
72 public void addChildren(TimeRangeEvent newEvent
) {
73 if ((newEvent
!= null)) {
74 this.ChildEventLeafs
.add(newEvent
);
81 public Long
getResourceId() {
88 public void setResourceId(Long newResId
) {
89 this.resourceId
= newResId
;
95 public ResourceTypes
getType() {
102 public void setType(ResourceTypes type
) {
107 * Getter for traceId.<br>
108 * Note : traceId and groupName are the same for EventResource
112 public String
getTraceId() {
117 * Getter for traceId.<br>
118 * Note : traceId and groupName are the same for EventResource
122 public void setTraceId(String traceId
) {
123 this.groupName
= traceId
;
130 * @see java.lang.Object#toString()
133 // public String toString() {
134 // return getResourceId().toString() + ":" + getTraceId().toString() + ":"
135 // + getType().toString();
139 @SuppressWarnings("nls")
140 public String
toString() {
141 return "[TimeRangeEventResource: " + super.toString() +
142 ",type=" + type
+ ",resourceId=" + resourceId
+ "]";
146 * Compare function to implement Comparable<br>
148 * Compare by traceId THEN IF EQUAL by resourceType THEN IF EQUAL by
151 * @param comparedResource
152 * The resource to compare to
154 * @return int 0 if equals, negative number if "smaller", positive if
159 public int compareTo(TimeRangeEventResource comparedResource
) {
160 int returnedValue
= 0;
162 if (comparedResource
!= null) {
163 // Compare by trace id first
164 returnedValue
= this.getTraceId().compareTo(
165 comparedResource
.getTraceId());
167 // If same, compare by resourceName
168 if (returnedValue
== 0) {
169 returnedValue
= this.getName().compareTo(
170 comparedResource
.getName());
172 // Finally, if same, compare by ResourceId
173 if (returnedValue
== 0) {
174 returnedValue
= this.getResourceId().compareTo(
175 comparedResource
.getResourceId());
181 return returnedValue
;
184 public abstract String
getStateMode(LttngTraceState traceState
);