package org.eclipse.linuxtools.tmf.core.trace;
import java.io.File;
+import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
return new ITmfTrace[] { trace };
}
+ /**
+ * Get the trace set of a given trace or experiment, including the
+ * experiment. For a standard trace, this is simply a set containing only
+ * that trace. For experiments, it is the set of all the traces contained in
+ * this experiment, along with the experiment.
+ *
+ * @param trace
+ * The trace or experiment
+ * @return The corresponding trace set, including the experiment
+ * @since 3.1
+ */
+ public static @NonNull Set<ITmfTrace> getTraceSetWithExperiment(ITmfTrace trace) {
+ if (trace == null) {
+ @SuppressWarnings("null")
+ @NonNull Set<ITmfTrace> emptySet = Collections.EMPTY_SET;
+ return emptySet;
+ }
+ if (trace instanceof TmfExperiment) {
+ TmfExperiment exp = (TmfExperiment) trace;
+ ITmfTrace[] traces = exp.getTraces();
+ Set<ITmfTrace> alltraces = new LinkedHashSet<>(Arrays.asList(traces));
+ alltraces.add(exp);
+ return alltraces;
+ }
+ @SuppressWarnings("null")
+ @NonNull Set<ITmfTrace> singleton = Collections.singleton(trace);
+ return singleton;
+ }
+
/**
* Return the path (as a string) to the directory for supplementary files to
* use with a given trace. If no supplementary file directory has been
org.eclipse.linuxtools.tmf.ctf.core.tests.statistics;x-internal:=true,
org.eclipse.linuxtools.tmf.ctf.core.tests.stubs,
org.eclipse.linuxtools.tmf.ctf.core.tests.tracemanager;x-internal:=true
-Import-Package: org.eclipse.test.performance
+Import-Package: com.google.common.collect,
+ org.eclipse.test.performance
import static org.junit.Assume.assumeTrue;
import java.io.File;
+import java.util.Set;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.junit.BeforeClass;
import org.junit.Test;
+import com.google.common.collect.ImmutableSet;
+
/**
* Test suite for the {@link TmfTraceManager}.
*
assertArrayEquals(expected, actual);
}
+ /**
+ * Test the contents of the complete trace set.
+ */
+ @Test
+ public void testTraceSetWithExperiment() {
+ /* Test with a trace */
+ Set<ITmfTrace> expected = ImmutableSet.of(trace1);
+ Set<ITmfTrace> actual = TmfTraceManager.getTraceSetWithExperiment(trace1);
+ assertEquals(1, actual.size());
+ assertEquals(expected, actual);
+
+ /* Test with an experiment */
+ TmfExperiment exp = createExperiment(trace1, trace2);
+ expected = ImmutableSet.of(trace1, trace2, exp);
+ actual = TmfTraceManager.getTraceSetWithExperiment(exp);
+ assertEquals(3, actual.size());
+ assertEquals(expected, actual);
+ }
+
/**
* Test the {@link TmfTraceManager#getSupplementaryFileDir} method.
*/