Commit | Line | Data |
---|---|---|
6e512b93 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 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 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
638eac44 | 12 | package org.eclipse.linuxtools.internal.lttng.ui.model.trange; |
6e512b93 | 13 | |
90e2b925 | 14 | import java.util.Iterator; |
6e512b93 ASL |
15 | import java.util.Vector; |
16 | ||
2fa130b8 PT |
17 | import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent; |
18 | import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; | |
6e512b93 ASL |
19 | |
20 | public class TimeRangeComposite extends TimeRangeComponent implements | |
21 | ITmfTimeAnalysisEntry { | |
22 | ||
23 | // ======================================================================== | |
24 | // Data | |
25 | // ======================================================================= | |
26 | /** | |
27 | * Type of Composites or Containers | |
28 | * <p> | |
29 | * PROPERTY: Refers to a sub-composite of a RESOURCE or a PROCESS e.g the | |
30 | * cpu which can vary over time and can have time range events associated to | |
31 | * it, and at the same time PROPERTY is associated to a Composite parent | |
32 | * like a PROCESS | |
33 | * </p> | |
34 | * <p> | |
35 | * PROCESS: A composite of time range events representing a Process | |
36 | * </p> | |
37 | * <p> | |
38 | * RESOURCE: A composite of time range events representing a resource i.g. | |
39 | * irq, softIrq, trap, bdev, cpu | |
40 | * </p> | |
41 | * | |
42 | * @author alvaro | |
43 | * | |
44 | */ | |
45 | public static enum CompositeType { | |
46 | UNKNOWN, PROPERTY, PROCESS, RESOURCE | |
47 | } | |
48 | ||
49 | protected final Vector<TimeRangeComponent> ChildEventLeafs = new Vector<TimeRangeComponent>(); | |
50 | protected final Vector<TimeRangeComponent> ChildEventComposites = new Vector<TimeRangeComponent>(); | |
51 | protected Integer id = 0; | |
52 | protected String name; | |
9c4eb5f7 FC |
53 | protected String groupName = ""; //$NON-NLS-1$ |
54 | protected String className = ""; //$NON-NLS-1$ | |
6e512b93 | 55 | protected CompositeType contType = CompositeType.UNKNOWN; |
28b94d61 | 56 | protected Long next_good_time = -1L; |
63eecb47 | 57 | /*Time of first event which trigger the creation of this local resource */ |
28b94d61 | 58 | protected Long insertionTime = -1L; |
6e512b93 ASL |
59 | |
60 | // ======================================================================== | |
61 | // Constructors | |
62 | // ======================================================================= | |
63eecb47 FC |
63 | public TimeRangeComposite(Integer id, Long stime, Long etime, String name, |
64 | CompositeType type, long insertionTime) { | |
6e512b93 ASL |
65 | super(stime, etime, null); |
66 | this.id = id; | |
67 | this.name = name; | |
68 | contType = type; | |
63eecb47 FC |
69 | this.insertionTime = insertionTime; |
70 | // Adjust the first good drawing position to the event time creating this resource | |
71 | next_good_time = insertionTime; | |
6e512b93 ASL |
72 | } |
73 | ||
63eecb47 FC |
74 | public TimeRangeComposite(Integer id, Long stime, Long etime, String name, |
75 | String groupName, String className, CompositeType type, | |
76 | long insertionTime) { | |
77 | this(id, stime, etime, name, type, insertionTime); | |
78 | this.groupName = groupName; | |
79 | this.className = className; | |
6e512b93 ASL |
80 | } |
81 | ||
82 | // ======================================================================== | |
83 | // Methods | |
84 | // ======================================================================= | |
85 | ||
86 | /* | |
87 | * (non-Javadoc) | |
88 | * | |
89 | * @see | |
90 | * org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent#getName() | |
91 | */ | |
92 | @Override | |
93 | public String getName() { | |
94 | return name; | |
95 | } | |
96 | ||
97 | /** | |
98 | * @param name | |
99 | */ | |
100 | public void setName(String name) { | |
101 | this.name = name; | |
102 | } | |
103 | ||
104 | /* | |
105 | * (non-Javadoc) | |
106 | * | |
107 | * @seeorg.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. | |
108 | * ITmfTimeAnalysisEntry#getGroupName() | |
109 | */ | |
d4011df2 | 110 | @Override |
6e512b93 ASL |
111 | public String getGroupName() { |
112 | return groupName; | |
113 | } | |
114 | ||
115 | /** | |
116 | * @param groupName | |
117 | */ | |
118 | public void setGroupName(String groupName) { | |
119 | this.groupName = groupName; | |
120 | } | |
121 | ||
122 | /* | |
123 | * (non-Javadoc) | |
124 | * | |
125 | * @seeorg.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. | |
126 | * ITmfTimeAnalysisEntry#getId() | |
127 | */ | |
d4011df2 | 128 | @Override |
6e512b93 ASL |
129 | public int getId() { |
130 | return id; | |
131 | } | |
132 | ||
133 | /** | |
134 | * @param id | |
135 | */ | |
136 | public void setId(int id) { | |
137 | this.id = id; | |
138 | } | |
139 | ||
140 | /** | |
141 | * @return | |
142 | */ | |
143 | public String getClassName() { | |
144 | return className; | |
145 | } | |
146 | ||
147 | /** | |
148 | * @param className | |
149 | */ | |
150 | public void setClassName(String className) { | |
151 | this.className = className; | |
152 | } | |
153 | ||
154 | /* | |
155 | * (non-Javadoc) | |
156 | * | |
157 | * @seeorg.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model. | |
158 | * ITmfTimeAnalysisEntry#getTraceEvents() | |
159 | */ | |
d4011df2 | 160 | @Override |
6e512b93 | 161 | @SuppressWarnings("unchecked") |
90e2b925 | 162 | @Deprecated public Vector<TimeRangeComponent> getTraceEvents() { |
6e512b93 ASL |
163 | return ChildEventLeafs; |
164 | } | |
165 | ||
90e2b925 | 166 | @Override |
e2561baf | 167 | @SuppressWarnings("unchecked") |
90e2b925 | 168 | public Iterator<TimeRangeComponent> getTraceEventsIterator() { |
ead3ac8f FC |
169 | Vector<TimeRangeComponent> clone = (Vector<TimeRangeComponent>) ChildEventLeafs.clone(); |
170 | return clone.iterator(); | |
90e2b925 FC |
171 | } |
172 | ||
173 | @Override | |
e2561baf | 174 | @SuppressWarnings("unchecked") |
90e2b925 | 175 | public Iterator<TimeRangeComponent> getTraceEventsIterator(long startTime, long stopTime, long visibleDuration) { |
ead3ac8f | 176 | return getTraceEventsIterator(); |
90e2b925 FC |
177 | } |
178 | ||
179 | @Override | |
180 | public void addTraceEvent(ITimeEvent event) { | |
181 | if (event instanceof TimeRangeComponent) { | |
182 | ChildEventLeafs.add((TimeRangeComponent) event); | |
183 | } | |
184 | } | |
185 | ||
186 | /** | |
6e512b93 ASL |
187 | * @return |
188 | */ | |
189 | public Vector<TimeRangeComponent> getChildEventComposites() { | |
190 | return ChildEventComposites; | |
191 | } | |
192 | ||
41dc35d0 FC |
193 | /** |
194 | * Represents the time where the next time range can start the drawing i.e. | |
195 | * right after previous time range. | |
196 | * | |
197 | * @return | |
198 | */ | |
199 | public long getNext_good_time() { | |
200 | return next_good_time; | |
201 | } | |
202 | ||
203 | /** | |
204 | * Represents the time where the next time range can start the drawing i.e. | |
205 | * right after previous time range. | |
206 | * | |
207 | * @param nextGoodTime | |
208 | */ | |
209 | public void setNext_good_time(long nextGoodTime) { | |
210 | next_good_time = nextGoodTime; | |
211 | } | |
212 | ||
213 | /** | |
b513223f | 214 | * Reset this resource to the construction state |
41dc35d0 FC |
215 | */ |
216 | public void reset() { | |
217 | getChildEventComposites().clear(); | |
218 | getTraceEvents().clear(); | |
63eecb47 FC |
219 | next_good_time = insertionTime; |
220 | } | |
221 | ||
222 | /** | |
223 | * Event Time reflecting the creation of this local resource e.g. at Reception of Fork, etc. | |
224 | * | |
225 | * @return | |
226 | */ | |
227 | public long getInsertionTime() { | |
228 | return insertionTime; | |
41dc35d0 | 229 | } |
0c2a2e08 FC |
230 | |
231 | @Override | |
9c4eb5f7 | 232 | @SuppressWarnings("nls") |
0c2a2e08 FC |
233 | public String toString() { |
234 | return "[TimeRangeComposite:" + super.toString() + | |
235 | ",id=" + id + ",name=" + name + ",group=" + groupName + ",class=" + className + | |
236 | ",ctype=" + contType + ",itime=" + insertionTime + | |
237 | ",leaves=" + ChildEventLeafs + ",composites=" + ChildEventComposites + "]"; | |
238 | } | |
239 | ||
6e512b93 | 240 | } |