tmf: Add a getTraceSet() method to the trace manager
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 8 May 2013 18:21:58 +0000 (14:21 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 8 May 2013 22:17:26 +0000 (18:17 -0400)
This allows getting the trace set (ie, encapsulating the TmfExperiment
instance check, etc.) for any trace, and not only the active one.

Change-Id: I876e8fb9956b10be6259341f49b54f3e9706be1f
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/12648
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>

org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceManager.java

index 53c7e03c0145dde8bc8655f18c6da7baa55169fa..48666112aa84560b8ec6df80048edfa8449033f8 100644 (file)
@@ -104,19 +104,14 @@ public final class TmfTraceManager {
     }
 
     /**
-     * Get the currently active trace set. For a 'normal' trace, this is simply
-     * an array with only that trace in it. For trace experiments, this will be
-     * an array containing the 'real' child traces in the experiment.
+     * Get the trace set of the currently active trace.
      *
      * @return The active trace set
+     * @see #getTraceSet(ITmfTrace)
      */
     public synchronized ITmfTrace[] getActiveTraceSet() {
         final ITmfTrace trace = fCurrentTrace;
-        if (trace instanceof TmfExperiment) {
-            final TmfExperiment exp = (TmfExperiment) trace;
-            return exp.getTraces();
-        }
-        return new ITmfTrace[] { trace };
+        return getTraceSet(trace);
     }
 
     private TmfTraceContext getCurrentTraceContext() {
@@ -128,6 +123,26 @@ public final class TmfTraceManager {
         return curCtx;
     }
 
+    /**
+     * Get the trace set of a given trace. For a standard trace, this is simply
+     * an array with only that trace in it. For experiments, this is an array of
+     * all the traces contained in this experiment.
+     *
+     * @param trace
+     *            The trace or experiment
+     * @return The corresponding trace set
+     */
+    public static ITmfTrace[] getTraceSet(ITmfTrace trace) {
+        if (trace == null) {
+            return null;
+        }
+        if (trace instanceof TmfExperiment) {
+            TmfExperiment exp = (TmfExperiment) trace;
+            return exp.getTraces();
+        }
+        return new ITmfTrace[] { trace };
+    }
+
     // ------------------------------------------------------------------------
     // Signal handlers
     // ------------------------------------------------------------------------
This page took 0.025653 seconds and 5 git commands to generate.