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