[TMF] Allow custom iterators by making the traces the iterator factories
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfIteratorManager.java
index b03fdbfd9c9a456dd1ed01db55cd10bc7c66f462..db14b396c201dc00b9b0d3998b6cc51da84343ab 100644 (file)
@@ -51,7 +51,10 @@ public abstract class CtfIteratorManager {
      *            the trace to register.
      */
     public static synchronized void removeTrace(final CtfTmfTrace trace) {
-        map.remove(trace);
+        CtfTraceManager mgr = map.remove(trace);
+        if (mgr != null) {
+            mgr.clear();
+        }
     }
 
     /**
@@ -133,7 +136,7 @@ class CtfTraceManager {
                 /*
                  * if we're not full yet, just add an element.
                  */
-                retVal = new CtfIterator(fTrace);
+                retVal = fTrace.createIterator();
                 addElement(context, retVal);
 
             } else {
@@ -142,8 +145,10 @@ class CtfTraceManager {
                  */
                 retVal = replaceRandomElement(context);
             }
-            final CtfLocationData location = (CtfLocationData) context.getLocation().getLocation();
-            retVal.seek( location);
+            if (context.getLocation() != null) {
+                final CtfLocationData location = (CtfLocationData) context.getLocation().getLocationInfo();
+                retVal.seek(location);
+            }
         }
         return retVal;
     }
@@ -187,4 +192,11 @@ class CtfTraceManager {
         return elem;
     }
 
+    void clear() {
+        for (CtfIterator iterator : fMap.values()) {
+            iterator.dispose();
+        }
+        fMap.clear();
+        fRandomAccess.clear();
+    }
 }
This page took 0.024386 seconds and 5 git commands to generate.