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