Contribution for Bug353020
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / experiment / TmfExperimentContext.java
index 6814225db83ad67e776585cd09924c38c3be9b7d..3d4981cbc118f04d045dc1f05e3a39f8e12df4b8 100644 (file)
@@ -46,7 +46,7 @@ public class TmfExperimentContext extends TmfContext {
        private ITmfTrace[]  fTraces = new ITmfTrace[0];
        private TmfContext[] fContexts;
        private TmfEvent[]   fEvents;
-       private int lastTrace;
+       private int lastTraceRead;
 
        // ------------------------------------------------------------------------
        // Constructors
@@ -69,9 +69,9 @@ public class TmfExperimentContext extends TmfContext {
                        }
                }
                
-               setLocation(new TmfExperimentLocation(locations, ranks));
+               setLocation(new TmfExperimentLocation(new TmfLocationArray(locations), ranks));
                setRank(rank);
-               lastTrace = NO_TRACE;
+               lastTraceRead = NO_TRACE;
        }
 
        public TmfExperimentContext(ITmfTrace[] traces) {
@@ -81,9 +81,10 @@ public class TmfExperimentContext extends TmfContext {
        public TmfExperimentContext(TmfExperimentContext other) {
                this(other.fTraces, other.cloneContexts());
                fEvents = other.fEvents;
-               setLocation(other.getLocation().clone());
+               if (other.getLocation() != null)
+                       setLocation(other.getLocation().clone());
                setRank(other.getRank());
-               setLastTrace(other.lastTrace);
+               setLastTrace(other.lastTraceRead);
        }
 
        private TmfContext[] cloneContexts() {
@@ -110,11 +111,41 @@ public class TmfExperimentContext extends TmfContext {
        }
 
        public int getLastTrace() {
-               return lastTrace;
+               return lastTraceRead;
        }
 
        public void setLastTrace(int newIndex) {
-               lastTrace = newIndex;
+               lastTraceRead = newIndex;
        }
 
+       // ------------------------------------------------------------------------
+       // Object
+       // ------------------------------------------------------------------------
+
+    @Override
+    public int hashCode() {
+               int result = 17;
+       for (int i = 0; i < fTraces.length; i++) {
+               result = 37 * result + fTraces[i].hashCode();
+               result = 37 * result + fContexts[i].hashCode();
+       }
+       return result;
+    }
+    @Override
+    public boolean equals(Object other) {
+       if (!(other instanceof TmfExperimentContext)) {
+               return false;
+       }
+       TmfExperimentContext o = (TmfExperimentContext) other;
+       boolean isEqual = true;
+       int i = 0;
+       while (isEqual && i < fTraces.length) {
+               isEqual &= fTraces[i].equals(o.fTraces[i]);
+               isEqual &= fContexts[i].equals(o.fContexts[i]);
+               i++;
+       }
+       return isEqual;
+    }
 }
This page took 0.049305 seconds and 5 git commands to generate.