--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 É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:
+ * Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.statesystem;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * Interface for analysis modules providing state systems.
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+@NonNullByDefault
+public interface ITmfAnalysisModuleWithStateSystems {
+
+ /**
+ * Return a specific state system provided by this analysis.
+ *
+ * @param id
+ * The ID of the state system
+ * @return The state system corresponding to the given ID, null if there is
+ * no match.
+ */
+ @Nullable
+ ITmfStateSystem getStateSystem(String id);
+
+ /**
+ * FIXME The ID's should be saved in the state system themselves
+ * (ITmfStateSystem.getId()), so this will eventually not be needed.
+ *
+ * Return the ID of a given state system.
+ *
+ * @param ss
+ * The state system for which you want the ID, null if there is
+ * no match.
+ * @return The corresponding state system
+ */
+ @Nullable
+ String getStateSystemId(ITmfStateSystem ss);
+
+ /**
+ * Return all the state systems provided by this analysis module, in
+ * Iterable format.
+ *
+ * @return The state systems
+ */
+ Iterable<ITmfStateSystem> getStateSystems();
+
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2013 É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:
- * Geneviève Bastien - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.statesystem;
-
-import java.util.Map;
-
-/**
- * Interface for analysis modules providing state systems
- *
- * @author Geneviève Bastien
- * @since 3.0
- */
-public interface ITmfStateSystemAnalysisModule {
-
- /**
- * Return a map of all state systems this analysis is owner of. The key is
- * the ID of the state system and the value is the state system itself.
- *
- * @return A map of state sytems
- */
- Map<String, ITmfStateSystem> getStateSystems();
-
-}
package org.eclipse.linuxtools.tmf.core.statesystem;
import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Collections;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
* @since 3.0
*/
public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisModule
- implements ITmfStateSystemAnalysisModule {
+ implements ITmfAnalysisModuleWithStateSystems {
- private ITmfStateSystem fStateSystem = null;
private static final String EXTENSION = ".ht"; //$NON-NLS-1$
+ private ITmfStateSystem fStateSystem = null;
+
/**
* State system backend types
*
fStateSystem.dispose();
}
+ // ------------------------------------------------------------------------
+ // ITmfAnalysisModuleWithStateSystems
+ // ------------------------------------------------------------------------
+
+ @Override
+ public ITmfStateSystem getStateSystem(@NonNull String id) {
+ if (id.equals(getId())) {
+ return fStateSystem;
+ }
+ return null;
+ }
+
+ @Override
+ public String getStateSystemId(@NonNull ITmfStateSystem ss) {
+ return getId();
+ }
+
+ @SuppressWarnings("null")
@Override
- public Map<String, ITmfStateSystem> getStateSystems() {
- Map<String, ITmfStateSystem> map = new HashMap<>();
- map.put(getId(), fStateSystem);
- return map;
+ @NonNull
+ public Iterable<ITmfStateSystem> getStateSystems() {
+ return Collections.singleton(fStateSystem);
}
}
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystemAnalysisModule;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems;
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
* @return The map of state systems
* @since 2.0
* @deprecated State systems now should be provided by analysis and use
- * {@link ITmfStateSystemAnalysisModule} and retrieve the modules
+ * {@link ITmfAnalysisModuleWithStateSystems} and retrieve the modules
* with {@link TmfTrace#getAnalysisModules(Class)} with Class
* being TmfStateSystemAnalysisModule.class
*/
* The already-built state system
* @since 2.0
* @deprecated State systems now should be provided by analysis and use
- * {@link ITmfStateSystemAnalysisModule}
+ * {@link ITmfAnalysisModuleWithStateSystems}
*/
@Deprecated
void registerStateSystem(String id, ITmfStateSystem ss);
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystemAnalysisModule;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems;
import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
* We will first do all the queries for this trace, then update that
* sub-tree in the UI thread.
*/
- Map<String, ITmfStateSystemAnalysisModule> modules = currentTrace.getAnalysisModules(ITmfStateSystemAnalysisModule.class);
+ Map<String, ITmfAnalysisModuleWithStateSystems> modules = currentTrace.getAnalysisModules(ITmfAnalysisModuleWithStateSystems.class);
final Map<String, ITmfStateSystem> sss = new HashMap<>();
final Map<String, List<ITmfStateInterval>> fullStates =
new LinkedHashMap<>();
- for (Entry<String, ITmfStateSystemAnalysisModule> entry : modules.entrySet()) {
+ for (Entry<String, ITmfAnalysisModuleWithStateSystems> entry : modules.entrySet()) {
/*
* FIXME: For now, this view is a way to execute and display
* state system. But with phase 2 of analysis API, we won't want
* to run state system that have not been requested. We will
* leave the title, but there won't be anything underneath.
*/
- ITmfStateSystemAnalysisModule module = entry.getValue();
+ ITmfAnalysisModuleWithStateSystems module = entry.getValue();
if (module instanceof IAnalysisModule) {
IAnalysisModule mod = (IAnalysisModule) module;
mod.schedule();
mod.waitForCompletion(new NullProgressMonitor());
}
- for (Entry<String, ITmfStateSystem> ssEntry : module.getStateSystems().entrySet()) {
- String ssName = ssEntry.getKey();
- ITmfStateSystem ss = ssEntry.getValue();
+ for (ITmfStateSystem ss : module.getStateSystems()) {
+ if (ss == null) {
+ continue;
+ }
+ String ssName = module.getStateSystemId(ss);
sss.put(ssName, ss);
- if (ss != null) {
- if (ts == -1 || ts < ss.getStartTime() || ts > ss.getCurrentEndTime()) {
- ts = ss.getStartTime();
- }
- try {
- fullStates.put(ssName, ss.queryFullState(ts));
- } catch (TimeRangeException e) {
- /* We already checked the limits ourselves */
- throw new IllegalStateException();
- } catch (StateSystemDisposedException e) {
- /* Probably shutting down, cancel and return */
- return;
- }
+
+ if (ts == -1 || ts < ss.getStartTime() || ts > ss.getCurrentEndTime()) {
+ ts = ss.getStartTime();
+ }
+ try {
+ fullStates.put(ssName, ss.queryFullState(ts));
+ } catch (TimeRangeException e) {
+ /* We already checked the limits ourselves */
+ throw new IllegalStateException();
+ } catch (StateSystemDisposedException e) {
+ /* Probably shutting down, cancel and return */
+ return;
}
}
}
/* For each trace... */
for (int traceNb = 0; traceNb < traces.length; traceNb++) {
- Map<String, ITmfStateSystemAnalysisModule> modules = traces[traceNb].getAnalysisModules(ITmfStateSystemAnalysisModule.class);
+ Map<String, ITmfAnalysisModuleWithStateSystems> modules = traces[traceNb].getAnalysisModules(ITmfAnalysisModuleWithStateSystems.class);
/* For each state system associated with this trace... */
int ssNb = 0;
- for (Entry<String, ITmfStateSystemAnalysisModule> module : modules.entrySet()) {
+ for (Entry<String, ITmfAnalysisModuleWithStateSystems> module : modules.entrySet()) {
/*
* Even though we only use the value, it just feels safer to
* iterate the same way as before to keep the order the same.
*/
- for (Entry<String, ITmfStateSystem> ssEntry : module.getValue().getStateSystems().entrySet()) {
- final ITmfStateSystem ss = ssEntry.getValue();
+ for (final ITmfStateSystem ss : module.getValue().getStateSystems()) {
final int traceNb1 = traceNb;
final int ssNb1 = ssNb;
if (ss != null) {