Commit | Line | Data |
---|---|---|
04835162 PT |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2012 Ericsson\r | |
3 | * \r | |
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 | |
8 | * \r | |
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.controlflow;\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 | |
2c33fc31 | 24 | public class ControlFlowEntry implements ITimeGraphEntry {\r |
49ffadb7 | 25 | private int fThreadQuark;\r |
04835162 | 26 | private CtfKernelTrace fTrace;\r |
49ffadb7 PT |
27 | private ControlFlowEntry fParent = null;\r |
28 | private ArrayList<ControlFlowEntry> fChildren = new ArrayList<ControlFlowEntry>();\r | |
04835162 PT |
29 | private String fName;\r |
30 | private int fThreadId;\r | |
3d90c4ff | 31 | private int fParentThreadId;\r |
49ffadb7 | 32 | private long fBirthTime = -1;\r |
04835162 PT |
33 | private long fStartTime = -1;\r |
34 | private long fEndTime = -1;\r | |
49ffadb7 PT |
35 | private List<ITimeEvent> fEventList = new ArrayList<ITimeEvent>();\r |
36 | private List<ITimeEvent> fZoomedEventList = null;\r | |
04835162 | 37 | \r |
3d90c4ff | 38 | public ControlFlowEntry(int threadQuark, CtfKernelTrace trace, String execName, int threadId, int parentThreadId, long birthTime, long startTime, long endTime) {\r |
49ffadb7 | 39 | fThreadQuark = threadQuark;\r |
04835162 PT |
40 | fTrace = trace;\r |
41 | fName = execName;\r | |
42 | fThreadId = threadId;\r | |
3d90c4ff | 43 | fParentThreadId = parentThreadId;\r |
49ffadb7 | 44 | fBirthTime = birthTime;\r |
04835162 PT |
45 | fStartTime = startTime;\r |
46 | fEndTime = endTime;\r | |
47 | }\r | |
48 | \r | |
49 | @Override\r | |
50 | public ITimeGraphEntry getParent() {\r | |
49ffadb7 | 51 | return fParent;\r |
04835162 PT |
52 | }\r |
53 | \r | |
54 | @Override\r | |
55 | public boolean hasChildren() {\r | |
49ffadb7 | 56 | return fChildren != null && fChildren.size() > 0;\r |
04835162 PT |
57 | }\r |
58 | \r | |
59 | @Override\r | |
49ffadb7 PT |
60 | public ControlFlowEntry[] getChildren() {\r |
61 | return fChildren.toArray(new ControlFlowEntry[0]);\r | |
04835162 PT |
62 | }\r |
63 | \r | |
64 | @Override\r | |
65 | public String getName() {\r | |
66 | return fName;\r | |
67 | }\r | |
68 | \r | |
04835162 PT |
69 | @Override\r |
70 | public long getStartTime() {\r | |
71 | return fStartTime;\r | |
72 | }\r | |
73 | \r | |
74 | @Override\r | |
49ffadb7 | 75 | public long getEndTime() {\r |
04835162 PT |
76 | return fEndTime;\r |
77 | }\r | |
78 | \r | |
8d8cb868 PT |
79 | @Override\r |
80 | public boolean hasTimeEvents() {\r | |
81 | return true;\r | |
82 | }\r | |
83 | \r | |
04835162 PT |
84 | @Override\r |
85 | public Iterator<ITimeEvent> getTimeEventsIterator() {\r | |
49ffadb7 | 86 | return new EventIterator(fEventList, fZoomedEventList);\r |
04835162 PT |
87 | }\r |
88 | \r | |
89 | @Override\r | |
90 | public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {\r | |
49ffadb7 | 91 | return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);\r |
04835162 PT |
92 | }\r |
93 | \r | |
49ffadb7 PT |
94 | public int getThreadQuark() {\r |
95 | return fThreadQuark;\r | |
96 | }\r | |
97 | \r | |
98 | public CtfKernelTrace getTrace() {\r | |
99 | return fTrace;\r | |
100 | }\r | |
101 | \r | |
102 | public int getThreadId() {\r | |
103 | return fThreadId;\r | |
104 | }\r | |
105 | \r | |
3d90c4ff PT |
106 | public int getParentThreadId() {\r |
107 | return fParentThreadId;\r | |
49ffadb7 PT |
108 | }\r |
109 | \r | |
110 | public long getBirthTime() {\r | |
111 | return fBirthTime;\r | |
112 | }\r | |
113 | \r | |
114 | public void addEvent(ITimeEvent event) {\r | |
115 | long start = event.getTime();\r | |
116 | long end = start + event.getDuration();\r | |
117 | synchronized (fEventList) {\r | |
118 | fEventList.add(event);\r | |
119 | if (fStartTime == -1 || start < fStartTime) {\r | |
120 | fStartTime = start;\r | |
121 | }\r | |
122 | if (fEndTime == -1 || end > fEndTime) {\r | |
123 | fEndTime = end;\r | |
124 | }\r | |
125 | }\r | |
126 | }\r | |
127 | \r | |
128 | public void setEventList(List<ITimeEvent> eventList) {\r | |
129 | fEventList = eventList;\r | |
130 | }\r | |
131 | \r | |
132 | public void setZoomedEventList(List<ITimeEvent> eventList) {\r | |
133 | fZoomedEventList = eventList;\r | |
134 | }\r | |
135 | \r | |
136 | public void addChild(ControlFlowEntry child) {\r | |
137 | child.fParent = this;\r | |
138 | fChildren.add(child);\r | |
139 | }\r | |
04835162 | 140 | }\r |