tmf: Rename packages to org.eclipse.tracecompass.*
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / resources / ResourcesEntry.java
CommitLineData
be222f56 1/*******************************************************************************
60ae41e1 2 * Copyright (c) 2012, 2014 Ericsson, École Polytechnique de Montréal
be222f56
PT
3 *
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
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
4999a196 11 * Geneviève Bastien - Move code to provide base classes for time graph view
be222f56
PT
12 *******************************************************************************/
13
14package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
15
72221aa4 16import org.eclipse.jdt.annotation.NonNull;
2bdf0193
AM
17import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
18import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
19import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
be222f56
PT
20
21/**
22 * An entry, or row, in the resource view
23 *
24 * @author Patrick Tasse
25 */
3e404d51 26public class ResourcesEntry extends TimeGraphEntry implements Comparable<ITimeGraphEntry> {
be222f56
PT
27
28 /** Type of resource */
29 public static enum Type {
30 /** Null resources (filler rows, etc.) */
31 NULL,
32 /** Entries for CPUs */
33 CPU,
34 /** Entries for IRQs */
35 IRQ,
36 /** Entries for Soft IRQ */
4999a196
GB
37 SOFT_IRQ
38 }
be222f56 39
be222f56 40 private final int fId;
72221aa4 41 private final @NonNull ITmfTrace fTrace;
4999a196
GB
42 private final Type fType;
43 private final int fQuark;
be222f56
PT
44
45 /**
4999a196 46 * Constructor
be222f56
PT
47 *
48 * @param quark
4999a196 49 * The attribute quark matching the entry
be222f56 50 * @param trace
4999a196
GB
51 * The trace on which we are working
52 * @param name
53 * The exec_name of this entry
54 * @param startTime
55 * The start time of this entry lifetime
56 * @param endTime
57 * The end time of this entry
be222f56 58 * @param type
4999a196 59 * The type of this entry
be222f56 60 * @param id
4999a196 61 * The id of this entry
be222f56 62 */
72221aa4
AM
63 public ResourcesEntry(int quark, @NonNull ITmfTrace trace, String name,
64 long startTime, long endTime, Type type, int id) {
1d46dc38 65 super(name, startTime, endTime);
be222f56 66 fId = id;
1d46dc38 67 fTrace = trace;
4999a196
GB
68 fType = type;
69 fQuark = quark;
be222f56
PT
70 }
71
72 /**
4999a196 73 * Constructor
be222f56 74 *
4999a196
GB
75 * @param trace
76 * The trace on which we are working
77 * @param name
78 * The exec_name of this entry
79 * @param startTime
80 * The start time of this entry lifetime
81 * @param endTime
82 * The end time of this entry
83 * @param id
84 * The id of this entry
be222f56 85 */
72221aa4
AM
86 public ResourcesEntry(@NonNull ITmfTrace trace, String name,
87 long startTime, long endTime, int id) {
4999a196 88 this(-1, trace, name, startTime, endTime, Type.NULL, id);
be222f56
PT
89 }
90
91 /**
4999a196 92 * Constructor
be222f56 93 *
4999a196
GB
94 * @param quark
95 * The attribute quark matching the entry
96 * @param trace
97 * The trace on which we are working
98 * @param startTime
99 * The start time of this entry lifetime
100 * @param endTime
101 * The end time of this entry
102 * @param type
103 * The type of this entry
104 * @param id
105 * The id of this entry
be222f56 106 */
72221aa4
AM
107 public ResourcesEntry(int quark, @NonNull ITmfTrace trace,
108 long startTime, long endTime, Type type, int id) {
4999a196 109 this(quark, trace, type.toString() + " " + id, startTime, endTime, type, id); //$NON-NLS-1$
be222f56
PT
110 }
111
112 /**
4999a196 113 * Get the entry's id
be222f56 114 *
4999a196 115 * @return the entry's id
be222f56 116 */
4999a196
GB
117 public int getId() {
118 return fId;
119 }
120
1d46dc38 121 /**
1cf25311 122 * Get the entry's trace
1d46dc38 123 *
1cf25311 124 * @return the entry's trace
1d46dc38 125 */
72221aa4 126 public @NonNull ITmfTrace getTrace() {
1d46dc38 127 return fTrace;
be222f56
PT
128 }
129
130 /**
131 * Get the entry Type of this entry. Uses the inner Type enum.
132 *
133 * @return The entry type
134 */
135 public Type getType() {
136 return fType;
137 }
138
139 /**
4999a196 140 * Retrieve the attribute quark that's represented by this entry.
be222f56 141 *
4999a196 142 * @return The integer quark The attribute quark matching the entry
be222f56 143 */
4999a196
GB
144 public int getQuark() {
145 return fQuark;
be222f56
PT
146 }
147
4999a196
GB
148 @Override
149 public boolean hasTimeEvents() {
150 if (fType == Type.NULL) {
151 return false;
be222f56 152 }
4999a196 153 return true;
be222f56
PT
154 }
155
3e404d51
AM
156 @Override
157 public int compareTo(ITimeGraphEntry other) {
158 if (!(other instanceof ResourcesEntry)) {
159 /* Should not happen, but if it does, put those entries at the end */
160 return -1;
161 }
162 ResourcesEntry o = (ResourcesEntry) other;
163
164 /*
165 * Resources entry names should all be of type "ABC 123"
166 *
167 * We want to filter on the Type first (the "ABC" part), then on the ID
168 * ("123") in numerical order (so we get 1,2,10 and not 1,10,2).
169 */
170 int ret = this.getType().compareTo(o.getType());
171 if (ret != 0) {
172 return ret;
173 }
174 return Integer.compare(this.getId(), o.getId());
be222f56 175 }
4999a196 176
be222f56 177}
This page took 0.063782 seconds and 5 git commands to generate.