requirements: Implement all level for event names and fields
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / trace / TmfTraceManager.java
index 71bd80d38b5ef7930f13d1723a7922175ce0e0ac..e819d31b119cf2e24bb6d50e7dba7824d52c904c 100644 (file)
@@ -34,17 +34,17 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.URIUtil;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
 import org.eclipse.tracecompass.tmf.core.signal.TmfEventFilterAppliedSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceModelSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
@@ -177,15 +177,15 @@ public final class TmfTraceManager {
      *            The trace or experiment
      * @return The corresponding trace set.
      */
-    public static @NonNull Collection<ITmfTrace> getTraceSet(ITmfTrace trace) {
+    public static @NonNull Collection<@NonNull ITmfTrace> getTraceSet(ITmfTrace trace) {
         if (trace == null) {
-            return NonNullUtils.checkNotNull(ImmutableSet.<ITmfTrace> of());
+            return ImmutableSet.of();
         }
-        List<ITmfTrace> traces = trace.getChildren(ITmfTrace.class);
+        List<@NonNull ITmfTrace> traces = trace.getChildren(ITmfTrace.class);
         if (traces.size() > 0) {
-            return NonNullUtils.checkNotNull(ImmutableSet.copyOf(traces));
+            return ImmutableSet.copyOf(traces);
         }
-        return NonNullUtils.checkNotNull(ImmutableSet.of(trace));
+        return ImmutableSet.of(trace);
     }
 
     /**
@@ -200,16 +200,16 @@ public final class TmfTraceManager {
      */
     public static @NonNull Collection<ITmfTrace> getTraceSetWithExperiment(ITmfTrace trace) {
         if (trace == null) {
-            return checkNotNull(ImmutableSet.<ITmfTrace> of());
+            return ImmutableSet.of();
         }
         if (trace instanceof TmfExperiment) {
             TmfExperiment exp = (TmfExperiment) trace;
             List<ITmfTrace> traces = exp.getTraces();
             Set<ITmfTrace> alltraces = new LinkedHashSet<>(traces);
             alltraces.add(exp);
-            return NonNullUtils.checkNotNull(ImmutableSet.copyOf(alltraces));
+            return ImmutableSet.copyOf(alltraces);
         }
-        return checkNotNull(Collections.singleton(trace));
+        return Collections.singleton(trace);
     }
 
     /**
@@ -282,14 +282,12 @@ public final class TmfTraceManager {
         final IFile editorFile = signal.getEditorFile();
         final ITmfTimestamp startTs = trace.getStartTime();
 
-        /* Calculate the initial time range */
-        final int SCALE = ITmfTimestamp.NANOSECOND_SCALE;
-        long offset = trace.getInitialRangeOffset().normalize(0, SCALE).getValue();
-        long endTime = startTs.normalize(0, SCALE).getValue() + offset;
+        long offset = trace.getInitialRangeOffset().toNanos();
+        long endTime = startTs.toNanos() + offset;
         final TmfTimeRange selectionRange = new TmfTimeRange(startTs, startTs);
-        final TmfTimeRange windowRange = new TmfTimeRange(startTs, new TmfTimestamp(endTime, SCALE));
+        final TmfTimeRange windowRange = new TmfTimeRange(startTs, TmfTimestamp.fromNanos(endTime));
 
-        final TmfTraceContext startCtx = new TmfTraceContext(selectionRange, windowRange, editorFile, null);
+        final TmfTraceContext startCtx = trace.createTraceContext(selectionRange, windowRange, editorFile, null);
 
         fTraces.put(trace, startCtx);
 
@@ -297,6 +295,17 @@ public final class TmfTraceManager {
         fCurrentTrace = trace;
     }
 
+    /**
+     * Signal propagator
+     * @param signal any signal
+     * @since 2.0
+     */
+    @TmfSignalHandler
+    public synchronized void signalReceived(final @NonNull TmfTraceModelSignal signal) {
+        fTraces.forEach((t, u) -> u.receive(signal));
+    }
+
+
     /**
      * Handler for the TmfTraceSelectedSignal.
      *
@@ -325,7 +334,7 @@ public final class TmfTraceManager {
         if (context == null) {
             throw new RuntimeException();
         }
-        fTraces.put(newTrace, new TmfTraceContext(context.getSelectionRange(),
+        fTraces.put(newTrace, newTrace.createTraceContext(context.getSelectionRange(),
                 context.getWindowRange(),
                 context.getEditorFile(),
                 signal.getEventFilter()));
@@ -374,7 +383,7 @@ public final class TmfTraceManager {
                  * else the same as the previous trace context.
                  */
                 TmfTimeRange newSelectionRange = new TmfTimeRange(beginTs, endTs);
-                TmfTraceContext newCtx = new TmfTraceContext(newSelectionRange,
+                TmfTraceContext newCtx = trace.createTraceContext(newSelectionRange,
                         prevCtx.getWindowRange(),
                         prevCtx.getEditorFile(),
                         prevCtx.getFilter());
@@ -409,7 +418,7 @@ public final class TmfTraceManager {
             TmfTimeRange newWindowTr = (targetTr == null ? prevCtx.getWindowRange() : targetTr);
 
             /* Keep the values from the old context, except for the window range */
-            TmfTraceContext newCtx = new TmfTraceContext(prevCtx.getSelectionRange(),
+            TmfTraceContext newCtx = trace.createTraceContext(prevCtx.getSelectionRange(),
                     newWindowTr, prevCtx.getEditorFile(), prevCtx.getFilter());
             entry.setValue(newCtx);
         }
This page took 0.025758 seconds and 5 git commands to generate.