01ac0ab169d5d5581d1b0149533bea2ea9101a84
1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.ui
.views
.controlflow
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Iterator
;
17 import java
.util
.List
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.ui
.views
.common
.EventIterator
;
20 import org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
.CtfKernelTrace
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
25 * An entry in the Control Flow view
27 public class ControlFlowEntry
implements ITimeGraphEntry
{
28 private final int fThreadQuark
;
29 private final CtfKernelTrace fTrace
;
30 private ControlFlowEntry fParent
= null;
31 private final ArrayList
<ControlFlowEntry
> fChildren
= new ArrayList
<ControlFlowEntry
>();
33 private final int fThreadId
;
34 private final int fParentThreadId
;
35 private long fStartTime
= -1;
36 private long fEndTime
= -1;
37 private List
<ITimeEvent
> fEventList
= new ArrayList
<ITimeEvent
>();
38 private List
<ITimeEvent
> fZoomedEventList
= null;
44 * The attribute quark matching the thread
46 * The trace on which we are working
48 * The exec_name of this entry
50 * The TID of the thread
51 * @param parentThreadId
52 * the Parent_TID of this thread
54 * The start time of this process's lifetime
56 * The end time of this process
58 public ControlFlowEntry(int threadQuark
, CtfKernelTrace trace
, String execName
, int threadId
, int parentThreadId
, long startTime
, long endTime
) {
59 fThreadQuark
= threadQuark
;
63 fParentThreadId
= parentThreadId
;
64 fStartTime
= startTime
;
69 public ITimeGraphEntry
getParent() {
74 public boolean hasChildren() {
75 return fChildren
!= null && fChildren
.size() > 0;
79 public List
<ControlFlowEntry
> getChildren() {
84 public String
getName() {
89 * Update the entry name
90 * @param execName the updated entry name
92 public void setName(String execName
) {
97 public long getStartTime() {
102 public long getEndTime() {
107 public boolean hasTimeEvents() {
112 public Iterator
<ITimeEvent
> getTimeEventsIterator() {
113 return new EventIterator(fEventList
, fZoomedEventList
);
117 public Iterator
<ITimeEvent
> getTimeEventsIterator(long startTime
, long stopTime
, long visibleDuration
) {
118 return new EventIterator(fEventList
, fZoomedEventList
, startTime
, stopTime
);
122 * Get the quark of the attribute matching this thread's TID
126 public int getThreadQuark() {
131 * Get the CTF trace object
135 public CtfKernelTrace
getTrace() {
140 * Get this entry's thread ID
144 public int getThreadId() {
149 * Get this thread's parent TID
153 public int getParentThreadId() {
154 return fParentThreadId
;
158 * Add an event to this process's timeline
163 public void addEvent(ITimeEvent event
) {
164 long start
= event
.getTime();
165 long end
= start
+ event
.getDuration();
166 synchronized (fEventList
) {
167 fEventList
.add(event
);
168 if (fStartTime
== -1 || start
< fStartTime
) {
171 if (fEndTime
== -1 || end
> fEndTime
) {
178 * Set the general event list of this entry
181 * The list of time events
183 public void setEventList(List
<ITimeEvent
> eventList
) {
184 fEventList
= eventList
;
188 * Set the zoomed event list of this entry
191 * The list of time events
193 public void setZoomedEventList(List
<ITimeEvent
> eventList
) {
194 fZoomedEventList
= eventList
;
198 * Add a child entry to this one (to show relationships between processes as
204 public void addChild(ControlFlowEntry child
) {
205 child
.fParent
= this;
206 fChildren
.add(child
);
This page took 0.035076 seconds and 5 git commands to generate.