Internalize lttng.ui APIs
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / internal / lttng / ui / model / trange / TimeRangeComposite.java
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 *******************************************************************************/
12 package org.eclipse.linuxtools.internal.lttng.ui.model.trange;
13
14 import java.util.Iterator;
15 import java.util.Vector;
16
17 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;
18 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
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;
53 protected String groupName = ""; //$NON-NLS-1$
54 protected String className = ""; //$NON-NLS-1$
55 protected CompositeType contType = CompositeType.UNKNOWN;
56 protected Long next_good_time = -1L;
57 /*Time of first event which trigger the creation of this local resource */
58 protected Long insertionTime = -1L;
59
60 // ========================================================================
61 // Constructors
62 // =======================================================================
63 public TimeRangeComposite(Integer id, Long stime, Long etime, String name,
64 CompositeType type, long insertionTime) {
65 super(stime, etime, null);
66 this.id = id;
67 this.name = name;
68 contType = type;
69 this.insertionTime = insertionTime;
70 // Adjust the first good drawing position to the event time creating this resource
71 next_good_time = insertionTime;
72 }
73
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;
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 */
110 @Override
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 */
128 @Override
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 */
160 @Override
161 @SuppressWarnings("unchecked")
162 @Deprecated public Vector<TimeRangeComponent> getTraceEvents() {
163 return ChildEventLeafs;
164 }
165
166 @Override
167 @SuppressWarnings("unchecked")
168 public Iterator<TimeRangeComponent> getTraceEventsIterator() {
169 Vector<TimeRangeComponent> clone = (Vector<TimeRangeComponent>) ChildEventLeafs.clone();
170 return clone.iterator();
171 }
172
173 @Override
174 @SuppressWarnings("unchecked")
175 public Iterator<TimeRangeComponent> getTraceEventsIterator(long startTime, long stopTime, long visibleDuration) {
176 return getTraceEventsIterator();
177 }
178
179 @Override
180 public void addTraceEvent(ITimeEvent event) {
181 if (event instanceof TimeRangeComponent) {
182 ChildEventLeafs.add((TimeRangeComponent) event);
183 }
184 }
185
186 /**
187 * @return
188 */
189 public Vector<TimeRangeComponent> getChildEventComposites() {
190 return ChildEventComposites;
191 }
192
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 /**
214 * Reset this resource to the construction state
215 */
216 public void reset() {
217 getChildEventComposites().clear();
218 getTraceEvents().clear();
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;
229 }
230
231 @Override
232 @SuppressWarnings("nls")
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
240 }
This page took 0.037764 seconds and 5 git commands to generate.