Ctf: Callsite bug fix when position is negative (binarySearch)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / resources / ResourcesEntry.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
14
15 import java.util.ArrayList;
16 import java.util.Iterator;
17 import java.util.List;
18
19 import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
20 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.EventIterator;
21 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
22 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
23
24 /**
25 * An entry, or row, in the resource view
26 *
27 * @author Patrick Tasse
28 */
29 public class ResourcesEntry implements ITimeGraphEntry {
30
31 /** Type of resource */
32 public static enum Type {
33 /** Null resources (filler rows, etc.) */
34 NULL,
35 /** Entries for CPUs */
36 CPU,
37 /** Entries for IRQs */
38 IRQ,
39 /** Entries for Soft IRQ */
40 SOFT_IRQ }
41
42 private final int fQuark;
43 private final LttngKernelTrace fTrace;
44 private ITimeGraphEntry fParent = null;
45 private final List<ITimeGraphEntry> children = null;
46 private final String fName;
47 private final Type fType;
48 private final int fId;
49 private long fStartTime;
50 private long fEndTime;
51 private List<ITimeEvent> fEventList = new ArrayList<ITimeEvent>();
52 private List<ITimeEvent> fZoomedEventList = null;
53
54 /**
55 * Standard constructor
56 *
57 * @param quark
58 * The quark of the state system attribute whose state is shown
59 * on this row
60 * @param trace
61 * The trace that this view is talking about
62 * @param type
63 * Type of entry, see the Type enum
64 * @param id
65 * The integer id associated with this entry or row
66 */
67 public ResourcesEntry(int quark, LttngKernelTrace trace, Type type, int id) {
68 fQuark = quark;
69 fTrace = trace;
70 fType = type;
71 fId = id;
72 fName = type.toString() + ' ' + Integer.toString(id);
73 }
74
75 @Override
76 public ITimeGraphEntry getParent() {
77 return fParent;
78 }
79
80 @Override
81 public boolean hasChildren() {
82 return children != null && children.size() > 0;
83 }
84
85 @Override
86 public List<ITimeGraphEntry> getChildren() {
87 return children;
88 }
89
90 @Override
91 public String getName() {
92 return fName;
93 }
94
95 @Override
96 public long getStartTime() {
97 return fStartTime;
98 }
99
100 @Override
101 public long getEndTime() {
102 return fEndTime;
103 }
104
105 @Override
106 public boolean hasTimeEvents() {
107 return true;
108 }
109
110 @Override
111 public Iterator<ITimeEvent> getTimeEventsIterator() {
112 return new EventIterator(fEventList, fZoomedEventList);
113 }
114
115 @Override
116 public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
117 return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);
118 }
119
120 /**
121 * Assign a parent entry to this one, to organize them in a tree in the
122 * view.
123 *
124 * @param parent
125 * The parent entry
126 */
127 public void setParent(ITimeGraphEntry parent) {
128 fParent = parent;
129 }
130
131 /**
132 * Retrieve the attribute quark that's represented by this entry.
133 *
134 * @return The integer quark
135 */
136 public int getQuark() {
137 return fQuark;
138 }
139
140 /**
141 * Retrieve the trace that is associated to this Resource view.
142 *
143 * @return The LTTng 2 kernel trace
144 */
145 public LttngKernelTrace getTrace() {
146 return fTrace;
147 }
148
149 /**
150 * Get the entry Type of this entry. Uses the inner Type enum.
151 *
152 * @return The entry type
153 */
154 public Type getType() {
155 return fType;
156 }
157
158 /**
159 * Get the integer ID associated with this entry.
160 *
161 * @return The ID
162 */
163 public int getId() {
164 return fId;
165 }
166
167 /**
168 * Assign the target event list to this view.
169 *
170 * @param eventList
171 * The list of time events
172 */
173 public void setEventList(List<ITimeEvent> eventList) {
174 fEventList = eventList;
175 if (eventList != null && eventList.size() > 0) {
176 fStartTime = eventList.get(0).getTime();
177 ITimeEvent lastEvent = eventList.get(eventList.size() - 1);
178 fEndTime = lastEvent.getTime() + lastEvent.getDuration();
179 }
180 }
181
182 /**
183 * Assign the zoomed event list to this view.
184 *
185 * @param eventList
186 * The list of "zoomed" time events
187 */
188 public void setZoomedEventList(List<ITimeEvent> eventList) {
189 fZoomedEventList = eventList;
190 }
191 }
This page took 0.035276 seconds and 5 git commands to generate.