tmf: import bug fix
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / resources / ResourcesEntry.java
CommitLineData
be222f56 1/*******************************************************************************
4999a196 2 * Copyright (c) 2012, 2013 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
d3ba47d4 16import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
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;
4999a196
GB
39 private final Type fType;
40 private final int fQuark;
be222f56
PT
41
42 /**
4999a196 43 * Constructor
be222f56
PT
44 *
45 * @param quark
4999a196 46 * The attribute quark matching the entry
be222f56 47 * @param trace
4999a196
GB
48 * The trace on which we are working
49 * @param name
50 * The exec_name of this entry
51 * @param startTime
52 * The start time of this entry lifetime
53 * @param endTime
54 * The end time of this entry
be222f56 55 * @param type
4999a196 56 * The type of this entry
be222f56 57 * @param id
4999a196 58 * The id of this entry
be222f56 59 */
4999a196
GB
60 public ResourcesEntry(int quark, LttngKernelTrace trace, String name, long startTime, long endTime, Type type, int id) {
61 super(quark, trace, name, startTime, endTime);
be222f56 62 fId = id;
4999a196
GB
63 fType = type;
64 fQuark = quark;
be222f56
PT
65 }
66
67 /**
4999a196 68 * Constructor
be222f56 69 *
4999a196
GB
70 * @param trace
71 * The trace on which we are working
72 * @param name
73 * The exec_name of this entry
74 * @param startTime
75 * The start time of this entry lifetime
76 * @param endTime
77 * The end time of this entry
78 * @param id
79 * The id of this entry
be222f56 80 */
4999a196
GB
81 public ResourcesEntry(LttngKernelTrace trace, String name, long startTime, long endTime, int id) {
82 this(-1, trace, name, startTime, endTime, Type.NULL, id);
be222f56
PT
83 }
84
85 /**
4999a196 86 * Constructor
be222f56 87 *
4999a196
GB
88 * @param quark
89 * The attribute quark matching the entry
90 * @param trace
91 * The trace on which we are working
92 * @param startTime
93 * The start time of this entry lifetime
94 * @param endTime
95 * The end time of this entry
96 * @param type
97 * The type of this entry
98 * @param id
99 * The id of this entry
be222f56 100 */
4999a196
GB
101 public ResourcesEntry(int quark, LttngKernelTrace trace, long startTime, long endTime, Type type, int id) {
102 this(quark, trace, type.toString() + " " + id, startTime, endTime, type, id); //$NON-NLS-1$
be222f56
PT
103 }
104
105 /**
4999a196 106 * Get the entry's id
be222f56 107 *
4999a196 108 * @return the entry's id
be222f56 109 */
4999a196
GB
110 public int getId() {
111 return fId;
112 }
113
114 @Override
d3ba47d4 115 public LttngKernelTrace getTrace() {
4999a196 116 return (LttngKernelTrace) super.getTrace();
be222f56
PT
117 }
118
119 /**
120 * Get the entry Type of this entry. Uses the inner Type enum.
121 *
122 * @return The entry type
123 */
124 public Type getType() {
125 return fType;
126 }
127
128 /**
4999a196 129 * Retrieve the attribute quark that's represented by this entry.
be222f56 130 *
4999a196 131 * @return The integer quark The attribute quark matching the entry
be222f56 132 */
4999a196
GB
133 public int getQuark() {
134 return fQuark;
be222f56
PT
135 }
136
4999a196
GB
137 @Override
138 public boolean hasTimeEvents() {
139 if (fType == Type.NULL) {
140 return false;
be222f56 141 }
4999a196 142 return true;
be222f56
PT
143 }
144
145 /**
4999a196 146 * Add a child to this entry of type ResourcesEntry
be222f56 147 *
4999a196
GB
148 * @param entry
149 * The entry to add
be222f56 150 */
4999a196
GB
151 public void addChild(ResourcesEntry entry) {
152 int index;
153 for (index = 0; index < getChildren().size(); index++) {
154 ResourcesEntry other = (ResourcesEntry) getChildren().get(index);
155 if (entry.getType().compareTo(other.getType()) < 0) {
156 break;
157 } else if (entry.getType().equals(other.getType())) {
158 if (entry.getId() < other.getId()) {
159 break;
160 }
161 }
162 }
163
164 entry.setParent(this);
165 getChildren().add(index, entry);
be222f56 166 }
4999a196 167
be222f56 168}
This page took 0.037369 seconds and 5 git commands to generate.