package org.eclipse.tracecompass.tmf.core.statesystem;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial.PartialHistoryBackend;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceCompleteness;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
/**
PARTIAL
}
-
/**
* Retrieve a state system belonging to trace, by passing the ID of the
* relevant analysis module.
*/
public static @Nullable ITmfStateSystem getStateSystem(ITmfTrace trace, String moduleId) {
TmfStateSystemAnalysisModule module =
- trace.getAnalysisModuleOfClass(TmfStateSystemAnalysisModule.class, moduleId);
+ TmfTraceUtils.getAnalysisModuleOfClass(trace, TmfStateSystemAnalysisModule.class, moduleId);
+ if (module != null) {
+ IStatus status = module.schedule();
+ if (status.isOK()) {
+ module.waitForInitialization();
+ return module.getStateSystem();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve a state system belonging to trace, by passing the class of the
+ * relevant analysis module. If many modules of the same class exists, the
+ * state system of the first one will be returned.
+ *
+ * This will start the execution of the analysis module, and start the
+ * construction of the state system, if needed.
+ *
+ * @param trace
+ * The trace for which you want the state system
+ * @param clazz
+ * The class of the state system module to retrieve
+ * @return The state system, or null if there was no match
+ */
+ public static @Nullable ITmfStateSystem getStateSystemByModuleClass(ITmfTrace trace, Class<? extends TmfStateSystemAnalysisModule> clazz) {
+ TmfStateSystemAnalysisModule module = null;
+ for (TmfStateSystemAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, clazz)) {
+ module = mod;
+ break;
+ }
if (module != null) {
IStatus status = module.schedule();
if (status.isOK()) {
this.sci = sp;
// sci.getTrace() will eventually return a @NonNull
- @SuppressWarnings("null")
- @NonNull ITmfTrace tr = sci.getTrace();
- trace = tr;
+ trace = checkNotNull(sci.getTrace());
}
@Override
public Iterable<ITmfStateSystem> getStateSystems() {
- @SuppressWarnings("null")
- @NonNull Iterable<ITmfStateSystem> ret = Collections.singleton((ITmfStateSystem) fStateSystem);
- return ret;
+ return checkNotNull(Collections.<ITmfStateSystem> singleton(fStateSystem));
}
/**