tmf: Split the state system in a separate plugin
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / controlflow / ControlFlowEntry.java
index 12da4aedf069cb661fa70323a639db8110585130..598deee1c145dcbb75b4fec8f1962dcc8f791b68 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;\r
-\r
-import java.util.Iterator;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
-\r
-public class ControlFlowEntry implements ITimeGraphEntry, Comparable<ControlFlowEntry> {\r
-    private CtfKernelTrace fTrace;\r
-    private ITimeGraphEntry parent = null;\r
-    private ITimeGraphEntry[] children = null;\r
-    private String fName;\r
-    private int fThreadId;\r
-    private int fPpid;\r
-    private long fStartTime = -1;\r
-    private long fEndTime = -1;\r
-    List<ITimeEvent> list = new LinkedList<ITimeEvent>();\r
-\r
-    public ControlFlowEntry(CtfKernelTrace trace, String execName, int threadId, int ppid, long startTime, long endTime) {\r
-        fTrace = trace;\r
-        fName = execName;\r
-        fThreadId = threadId;\r
-        fPpid = ppid;\r
-        fStartTime = startTime;\r
-        fEndTime = endTime;\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry getParent() {\r
-        return parent;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasChildren() {\r
-        return children != null && children.length > 0;\r
-    }\r
-\r
-    @Override\r
-    public ITimeGraphEntry[] getChildren() {\r
-        return children;\r
-    }\r
-\r
-    @Override\r
-    public String getName() {\r
-        return fName;\r
-    }\r
-\r
-    public int getThreadId() {\r
-        return fThreadId;\r
-    }\r
-\r
-    public int getPPID() {\r
-        return fPpid;\r
-    }\r
-\r
-    @Override\r
-    public long getStartTime() {\r
-        return fStartTime;\r
-    }\r
-\r
-    @Override\r
-    public long getStopTime() {\r
-        return fEndTime;\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator() {\r
-        return list.iterator();\r
-    }\r
-\r
-    @Override\r
-    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {\r
-        return getTimeEventsIterator();\r
-    }\r
-\r
-    public void addTraceEvent(ITimeEvent event) {\r
-        long time = event.getTime();\r
-        list.add(event);\r
-        if (fStartTime == -1 || time < fStartTime) {\r
-            fStartTime = time;\r
-        }\r
-        if (fEndTime == -1 || time > fEndTime) {\r
-            fEndTime = time;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int compareTo(ControlFlowEntry other) {\r
-        int result = this.fThreadId < other.fThreadId ? -1 : this.fThreadId > other.fThreadId ? 1 : 0;\r
-        if (result == 0) {\r
-            result = this.fStartTime < other.fStartTime ? -1 : this.fStartTime > other.fStartTime ? 1 : 0;\r
-        }\r
-        return result;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Ericsson, École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *   Geneviève Bastien - Move code to provide base classes for time graph view
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
+
+/**
+ * An entry in the Control Flow view
+ */
+public class ControlFlowEntry extends TimeGraphEntry {
+
+    private final ITmfTrace fTrace;
+    private final int fThreadId;
+    private final int fParentThreadId;
+    private final int fThreadQuark;
+
+    /**
+     * Constructor
+     *
+     * @param quark
+     *            The attribute quark matching the thread
+     * @param trace
+     *            The trace on which we are working
+     * @param execName
+     *            The exec_name of this entry
+     * @param threadId
+     *            The TID of the thread
+     * @param parentThreadId
+     *            the Parent_TID of this thread
+     * @param startTime
+     *            The start time of this process's lifetime
+     * @param endTime
+     *            The end time of this process
+     */
+    public ControlFlowEntry(int quark, ITmfTrace trace, String execName, int threadId, int parentThreadId, long startTime, long endTime) {
+        super(execName, startTime, endTime);
+        fTrace = trace;
+        fThreadId = threadId;
+        fParentThreadId = parentThreadId;
+        fThreadQuark = quark;
+    }
+
+    /**
+     * Get this entry's thread ID
+     *
+     * @return The TID
+     */
+    public int getThreadId() {
+        return fThreadId;
+    }
+
+    /**
+     * Get the entry's trace
+     *
+     * @return the entry's trace
+     */
+    public ITmfTrace getTrace() {
+        return fTrace;
+    }
+
+    /**
+     * Get this thread's parent TID
+     *
+     * @return The "PTID"
+     */
+    public int getParentThreadId() {
+        return fParentThreadId;
+    }
+
+    /**
+     * Get the quark of the attribute matching this thread's TID
+     *
+     * @return The quark
+     */
+    public int getThreadQuark() {
+        return fThreadQuark;
+    }
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + '(' + getName() + '[' + fThreadId + "])"; //$NON-NLS-1$
+    }
+}
This page took 0.026712 seconds and 5 git commands to generate.