tmf: Update copyright headers in tmf.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / trace / TmfExperimentContext.java
index 2ea22050bff036cfb3acfb2ccc3af0e22c6d5f69..bdeaa775db90625d24936161b3087efca7f65fc7 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,13 +9,13 @@
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Francois Chouinard - Put in shape for 1.0
+ *   Patrick Tasse - Updated for removal of context clone
  *******************************************************************************/
 
 package org.eclipse.linuxtools.internal.tmf.core.trace;
 
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
 
 /**
@@ -25,9 +25,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
  * can pick the next one in chronological order.
  * <p>
  * This implies that the "next" event from each trace has already been
- * read and that we at least know its timestamp. This doesn't imply that a
- * full parse of the event content was performed (read: the legacy LTTng works
- * like this...).
+ * read and that we at least know its timestamp.
  * <p>
  * The last trace refers to the trace from which the last event was "consumed"
  * at the experiment level.
@@ -58,75 +56,25 @@ public class TmfExperimentContext extends TmfContext {
     /**
      * Standard constructor
      *
-     * @param contexts
-     *            The matching context for each trace in the experiment
+     * @param nbTraces
+     *            The number of traces in the experiment
      */
-    public TmfExperimentContext(final ITmfContext[] contexts) {
+    public TmfExperimentContext(final int nbTraces) {
         super();
-        fContexts = contexts;
-        fEvents = new ITmfEvent[fContexts.length];
-        final ITmfLocation<?>[] locations = new ITmfLocation[fContexts.length];
-
-        setLocation(new TmfExperimentLocation(new TmfLocationArray(locations.clone())));
-
-        final long[] ranks = new long[fContexts.length];
-        long rank = 0;
-        for (int i = 0; i < fContexts.length; i++) {
-            if (contexts[i] != null) {
-                locations[i] = contexts[i].getLocation();
-                ranks[i] = contexts[i].getRank();
-                rank += contexts[i].getRank();
-            }
-        }
-
-//        setLocation(new TmfExperimentLocation(new TmfLocationArray(locations)));
-        setRank(rank);
+        fContexts = new ITmfContext[nbTraces];
+        fEvents = new ITmfEvent[nbTraces];
         fLastTraceRead = NO_TRACE;
     }
 
-    /**
-     * Copy constructor
-     *
-     * @param other
-     *            The experiment context to copy
-     */
-    public TmfExperimentContext(final TmfExperimentContext other) {
-        this(other.cloneContexts());
-        fEvents = other.fEvents;
-        if (other.getLocation() != null) {
-            setLocation(other.getLocation().clone());
-        }
-        setRank(other.getRank());
-        setLastTrace(other.fLastTraceRead);
-    }
-
     /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext#clone()
+     * @see org.eclipse.linuxtools.tmf.core.trace.TmfContext#dispose()
      */
     @Override
-    public TmfExperimentContext clone() {
-        TmfExperimentContext clone = null;
-        clone = (TmfExperimentContext) super.clone();
-        clone.fContexts = cloneContexts();
-        clone.fEvents = cloneEvents();
-        clone.fLastTraceRead = fLastTraceRead;
-        return clone;
-    }
-
-    private ITmfContext[] cloneContexts() {
-        final ITmfContext[] contexts = new ITmfContext[fContexts.length];
-        for (int i = 0; i < fContexts.length; i++) {
-            contexts[i] = (fContexts[i] != null) ? fContexts[i].clone() : null;
-        }
-        return contexts;
-    }
-
-    private ITmfEvent[] cloneEvents() {
-        final ITmfEvent[] events = new ITmfEvent[fEvents.length];
-        for (int i = 0; i < fEvents.length; i++) {
-            events[i] = (fEvents[i] != null) ? fEvents[i].clone() : null;
+    public void dispose() {
+        for (ITmfContext context : fContexts) {
+            context.dispose();
         }
-        return events;
+        super.dispose();
     }
 
     // ------------------------------------------------------------------------
This page took 0.030124 seconds and 5 git commands to generate.