tmf: Add percentage on Statistics view
[deliverable/tracecompass.git] / org.eclipse.linuxtools.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
1cf25311 16import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
4999a196 17import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
be222f56
PT
18
19/**
20 * An entry, or row, in the resource view
21 *
22 * @author Patrick Tasse
23 */
4999a196 24public class ResourcesEntry extends TimeGraphEntry {
be222f56
PT
25
26 /** Type of resource */
27 public static enum Type {
28 /** Null resources (filler rows, etc.) */
29 NULL,
30 /** Entries for CPUs */
31 CPU,
32 /** Entries for IRQs */
33 IRQ,
34 /** Entries for Soft IRQ */
4999a196
GB
35 SOFT_IRQ
36 }
be222f56 37
be222f56 38 private final int fId;
1cf25311 39 private final ITmfTrace fTrace;
4999a196
GB
40 private final Type fType;
41 private final int fQuark;
be222f56
PT
42
43 /**
4999a196 44 * Constructor
be222f56
PT
45 *
46 * @param quark
4999a196 47 * The attribute quark matching the entry
be222f56 48 * @param trace
4999a196
GB
49 * The trace on which we are working
50 * @param name
51 * The exec_name of this entry
52 * @param startTime
53 * The start time of this entry lifetime
54 * @param endTime
55 * The end time of this entry
be222f56 56 * @param type
4999a196 57 * The type of this entry
be222f56 58 * @param id
4999a196 59 * The id of this entry
be222f56 60 */
1cf25311 61 public ResourcesEntry(int quark, ITmfTrace trace, String name, long startTime, long endTime, Type type, int id) {
1d46dc38 62 super(name, startTime, endTime);
be222f56 63 fId = id;
1d46dc38 64 fTrace = trace;
4999a196
GB
65 fType = type;
66 fQuark = quark;
be222f56
PT
67 }
68
69 /**
4999a196 70 * Constructor
be222f56 71 *
4999a196
GB
72 * @param trace
73 * The trace on which we are working
74 * @param name
75 * The exec_name of this entry
76 * @param startTime
77 * The start time of this entry lifetime
78 * @param endTime
79 * The end time of this entry
80 * @param id
81 * The id of this entry
be222f56 82 */
1cf25311 83 public ResourcesEntry(ITmfTrace trace, String name, long startTime, long endTime, int id) {
4999a196 84 this(-1, trace, name, startTime, endTime, Type.NULL, id);
be222f56
PT
85 }
86
87 /**
4999a196 88 * Constructor
be222f56 89 *
4999a196
GB
90 * @param quark
91 * The attribute quark matching the entry
92 * @param trace
93 * The trace on which we are working
94 * @param startTime
95 * The start time of this entry lifetime
96 * @param endTime
97 * The end time of this entry
98 * @param type
99 * The type of this entry
100 * @param id
101 * The id of this entry
be222f56 102 */
1cf25311 103 public ResourcesEntry(int quark, ITmfTrace trace, long startTime, long endTime, Type type, int id) {
4999a196 104 this(quark, trace, type.toString() + " " + id, startTime, endTime, type, id); //$NON-NLS-1$
be222f56
PT
105 }
106
107 /**
4999a196 108 * Get the entry's id
be222f56 109 *
4999a196 110 * @return the entry's id
be222f56 111 */
4999a196
GB
112 public int getId() {
113 return fId;
114 }
115
1d46dc38 116 /**
1cf25311 117 * Get the entry's trace
1d46dc38 118 *
1cf25311 119 * @return the entry's trace
1d46dc38 120 */
1cf25311 121 public ITmfTrace getTrace() {
1d46dc38 122 return fTrace;
be222f56
PT
123 }
124
125 /**
126 * Get the entry Type of this entry. Uses the inner Type enum.
127 *
128 * @return The entry type
129 */
130 public Type getType() {
131 return fType;
132 }
133
134 /**
4999a196 135 * Retrieve the attribute quark that's represented by this entry.
be222f56 136 *
4999a196 137 * @return The integer quark The attribute quark matching the entry
be222f56 138 */
4999a196
GB
139 public int getQuark() {
140 return fQuark;
be222f56
PT
141 }
142
4999a196
GB
143 @Override
144 public boolean hasTimeEvents() {
145 if (fType == Type.NULL) {
146 return false;
be222f56 147 }
4999a196 148 return true;
be222f56
PT
149 }
150
151 /**
4999a196 152 * Add a child to this entry of type ResourcesEntry
be222f56 153 *
4999a196
GB
154 * @param entry
155 * The entry to add
be222f56 156 */
4999a196
GB
157 public void addChild(ResourcesEntry entry) {
158 int index;
159 for (index = 0; index < getChildren().size(); index++) {
160 ResourcesEntry other = (ResourcesEntry) getChildren().get(index);
161 if (entry.getType().compareTo(other.getType()) < 0) {
162 break;
163 } else if (entry.getType().equals(other.getType())) {
164 if (entry.getId() < other.getId()) {
165 break;
166 }
167 }
168 }
169
170 entry.setParent(this);
171 getChildren().add(index, entry);
be222f56 172 }
4999a196 173
be222f56 174}
This page took 0.044324 seconds and 5 git commands to generate.