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 / TmfTrace.java
index e1ded36144778dc56f706ab6613bd182624f81ec..ab6ccf5749ccc7759a722ff56bb886bb5468dbe5 100644 (file)
@@ -16,8 +16,6 @@
 
 package org.eclipse.tracecompass.tmf.core.trace;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
 import java.io.File;
 import java.util.Collection;
 import java.util.Collections;
@@ -39,6 +37,9 @@ import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisManager;
 import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
+import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects;
 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
@@ -51,7 +52,6 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform;
 import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
@@ -59,7 +59,6 @@ import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointI
 import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
 
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Multimap;
 
 /**
  * Abstract implementation of ITmfTrace.
@@ -98,12 +97,12 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     /**
      * Basic aspects that should be valid for all trace types.
      */
-    public static final @NonNull Collection<ITmfEventAspect> BASE_ASPECTS =
-            checkNotNull(ImmutableList.of(
-                    ITmfEventAspect.BaseAspects.TIMESTAMP,
-                    ITmfEventAspect.BaseAspects.EVENT_TYPE,
-                    ITmfEventAspect.BaseAspects.CONTENTS
-                    ));
+    public static final @NonNull Collection<@NonNull ITmfEventAspect<?>> BASE_ASPECTS =
+            ImmutableList.of(
+                    TmfBaseAspects.getTimestampAspect(),
+                    TmfBaseAspects.getEventTypeAspect(),
+                    TmfBaseAspects.getContentsAspect()
+                    );
 
     // ------------------------------------------------------------------------
     // Instance attributes
@@ -285,7 +284,8 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     protected IStatus executeAnalysis() {
         MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
 
-        Multimap<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules();
+        /* First modules are initialized */
+        Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules(this.getClass());
         for (IAnalysisModuleHelper helper : modules.values()) {
             try {
                 IAnalysisModule module = helper.newModule(this);
@@ -293,13 +293,17 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
                     continue;
                 }
                 fAnalysisModules.put(module.getId(), module);
-                if (module.isAutomatic()) {
-                    status.add(module.schedule());
-                }
             } catch (TmfAnalysisException e) {
                 status.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage()));
             }
         }
+
+        /* Once all modules are initialized, automatic modules are executed */
+        for (IAnalysisModule module : getAnalysisModules()) {
+            if (module.isAutomatic()) {
+                status.add(module.schedule());
+            }
+        }
         return status;
     }
 
@@ -318,7 +322,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     }
 
     @Override
-    public Iterable<ITmfEventAspect> getEventAspects() {
+    public Iterable<ITmfEventAspect<?>> getEventAspects() {
         /* By default we provide only the base aspects valid for all trace types */
         return BASE_ASPECTS;
     }
@@ -348,11 +352,6 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     // ITmfTrace - Basic getters
     // ------------------------------------------------------------------------
 
-    @Override
-    public Class<? extends ITmfEvent> getEventType() {
-        return super.getType();
-    }
-
     @Override
     public IResource getResource() {
         return fResource;
@@ -412,7 +411,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     @Override
     public ITmfTimestamp getInitialRangeOffset() {
         final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
-        return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
+        return TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE);
     }
 
     @Override
@@ -553,8 +552,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
         // parseEvent() does not update the context
         final ITmfEvent event = parseEvent(context);
         if (event != null) {
-            ITmfTimestamp timestamp = event.getTimestamp();
-            updateAttributes(context, timestamp);
+            updateAttributes(context, event);
             context.setLocation(getCurrentLocation());
             context.increaseRank();
         }
@@ -566,13 +564,31 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
      *
      * @param context the current trace context
      * @param timestamp the corresponding timestamp
+     * @deprecated Use {@link #updateAttributes(ITmfContext, ITmfEvent)}
      */
+    @Deprecated
     protected synchronized void updateAttributes(final ITmfContext context, final @NonNull ITmfTimestamp timestamp) {
+        updateAttributes(context, new TmfEvent(this, context.getRank(), timestamp, null, null));
+    }
+
+    /**
+     * Update the trace attributes
+     *
+     * @param context the current trace context
+     * @param event the corresponding event
+     * @since 1.1
+     */
+    protected synchronized void updateAttributes(final ITmfContext context, final @NonNull ITmfEvent event) {
+        ITmfTimestamp timestamp = event.getTimestamp();
+        ITmfTimestamp endTime = timestamp;
+        if (event instanceof ITmfLostEvent) {
+            endTime = ((ITmfLostEvent) event).getTimeRange().getEndTime();
+        }
         if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp) > 0)) {
             fStartTime = timestamp;
         }
-        if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(timestamp) < 0)) {
-            fEndTime = timestamp;
+        if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(endTime) < 0)) {
+            fEndTime = endTime;
         }
         if (context.hasValidRank()) {
             long rank = context.getRank();
@@ -709,7 +725,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
 
     @Override
     public @NonNull ITmfTimestamp createTimestamp(long ts) {
-        return new TmfNanoTimestamp(getTimestampTransform().transform(ts));
+        return TmfTimestamp.fromNanos(getTimestampTransform().transform(ts));
     }
 
     // ------------------------------------------------------------------------
This page took 0.027067 seconds and 5 git commands to generate.