[WIP] CFV Refactor
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / views / controlflow2 / ControlFlowTreeElement.java
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/views/controlflow2/ControlFlowTreeElement.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/views/controlflow2/ControlFlowTreeElement.java
new file mode 100644 (file)
index 0000000..3964d12
--- /dev/null
@@ -0,0 +1,51 @@
+package org.eclipse.tracecompass.internal.analysis.os.linux.core.views.controlflow2;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.views.timegraph2.TimeGraphTreeElement;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.views.timegraph2.statesystem.StateSystemTimeGraphTreeElement;
+
+public class ControlFlowTreeElement extends StateSystemTimeGraphTreeElement {
+
+    private static final String UNKNOWN_THREAD_NAME = "???"; //$NON-NLS-1$
+
+    private final int fTid;
+    private final String fThreadName;
+
+    public ControlFlowTreeElement(String tidStr, @Nullable String threadName,
+            List<TimeGraphTreeElement> children, int sourceQuark) {
+        super(getElementName(tidStr, threadName),
+                children,
+                sourceQuark);
+
+        if (tidStr.startsWith(Attributes.THREAD_0_PREFIX)) {
+            fTid = 0;
+        } else {
+            fTid = Integer.parseInt(tidStr);
+        }
+
+        fThreadName = (threadName == null ? UNKNOWN_THREAD_NAME : threadName);
+    }
+
+    private static String getElementName(String tidStr, @Nullable String threadName) {
+        String tidPart = tidStr;
+        if (tidPart.startsWith(Attributes.THREAD_0_PREFIX)) {
+            /* Display "0/0" instead of "0_0" */
+            tidPart = tidPart.replace('_', '/');
+        }
+
+        String threadNamePart = (threadName == null ? UNKNOWN_THREAD_NAME : threadName);
+        return (tidPart + " - " + threadNamePart); //$NON-NLS-1$
+    }
+
+    public int getTid() {
+        return fTid;
+    }
+
+    public String getThreadName() {
+        return fThreadName;
+    }
+
+}
This page took 0.024119 seconds and 5 git commands to generate.