tmf.ctf: Rename CtfIteratorManager classes
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 28 Oct 2014 19:36:14 +0000 (15:36 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 10 Nov 2014 01:35:24 +0000 (20:35 -0500)
This patch simply renames existing constructs related to TMF-CTF iterators
to better represent what they do, to help future refactoring:

CtfIteratorManager -> CtfIteratorCEO .It is a "meta-manager" that manages
all the existing, now-called CtfIteratorManager's. Silly name, but don't
worry it's temporary ;)

CtfTraceManager -> CtfIteratorManager. This is the object that manages all
the iterators of one trace. It should eventually be moved to inside the trace.

Change-Id: Ie5483844856610907d3e332307eb0844209a93ef
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/35614
Tested-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfIteratorCEO.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfIteratorManager.java
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfContext.java
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfTrace.java

diff --git a/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfIteratorCEO.java b/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfIteratorCEO.java
new file mode 100644 (file)
index 0000000..a0cfde5
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 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
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Matthew Khouzam - Initial API and implementation
+ *   Simon Delisle - Added a method to remove the iterator
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ctf.core;
+
+import java.util.HashMap;
+
+/**
+ * Ctf Iterator Manager, allows mapping of iterators (a limited resource) to
+ * contexts (many many resources).
+ *
+ * @author Matthew Khouzam
+ * @version 1.0
+ * @since 1.1
+ */
+public abstract class CtfIteratorCEO {
+    /*
+     * A side note synchronized works on the whole object, Therefore add and
+     * remove will be thread safe.
+     */
+
+    /*
+     * The map of traces to trace managers.
+     */
+    private static HashMap<CtfTmfTrace, CtfIteratorManager> map = new HashMap<>();
+
+    /**
+     * Registers a trace to the iterator manager, the trace can now get
+     * iterators.
+     *
+     * @param trace
+     *            the trace to register.
+     */
+    public static synchronized void addTrace(final CtfTmfTrace trace) {
+        map.put(trace, new CtfIteratorManager(trace));
+    }
+
+    /**
+     * Removes a trace to the iterator manager.
+     *
+     * @param trace
+     *            the trace to register.
+     */
+    public static synchronized void removeTrace(final CtfTmfTrace trace) {
+        CtfIteratorManager mgr = map.remove(trace);
+        if (mgr != null) {
+            mgr.clear();
+        }
+    }
+
+    /**
+     * Get an iterator for a given trace and context.
+     *
+     * @param trace
+     *            the trace
+     * @param ctx
+     *            the context
+     * @return the iterator
+     * @since 2.0
+     */
+    public static synchronized CtfIterator getIterator(final CtfTmfTrace trace,
+            final CtfTmfContext ctx) {
+        return map.get(trace).getIterator(ctx);
+    }
+
+    /**
+     * Remove an iterator for a given trace and context
+     *
+     * @param trace
+     *            the trace
+     * @param ctx
+     *            the context
+     * @since 2.1
+     */
+    public static synchronized void removeIterator(final CtfTmfTrace trace, final CtfTmfContext ctx) {
+        CtfIteratorManager traceManager = map.get(trace);
+        if (traceManager != null) {
+            traceManager.removeIterator(ctx);
+        }
+    }
+}
index 09ee972e59f413b3ce22f6fdd200a4418540ec05..29f01d10c2998dda927e50f435bfd8f4f9fa4c10 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License v1.0 which
@@ -7,9 +7,9 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Matthew Khouzam - Initial API and implementation
- *   Simon Delisle - Added a method to remove the iterator
+ *   Alexandre Montplaisir - Renamed/extracted from CtfTraceManager
  *******************************************************************************/
+
 package org.eclipse.tracecompass.tmf.ctf.core;
 
 import java.util.ArrayList;
@@ -17,86 +17,11 @@ import java.util.HashMap;
 import java.util.Random;
 
 /**
- * Ctf Iterator Manager, allows mapping of iterators (a limited resource) to
- * contexts (many many resources).
- *
- * @author Matthew Khouzam
- * @version 1.0
- * @since 1.1
- */
-public abstract class CtfIteratorManager {
-    /*
-     * A side note synchronized works on the whole object, Therefore add and
-     * remove will be thread safe.
-     */
-
-    /*
-     * The map of traces to trace managers.
-     */
-    private static HashMap<CtfTmfTrace, CtfTraceManager> map = new HashMap<>();
-
-    /**
-     * Registers a trace to the iterator manager, the trace can now get
-     * iterators.
-     *
-     * @param trace
-     *            the trace to register.
-     */
-    public static synchronized void addTrace(final CtfTmfTrace trace) {
-        map.put(trace, new CtfTraceManager(trace));
-    }
-
-    /**
-     * Removes a trace to the iterator manager.
-     *
-     * @param trace
-     *            the trace to register.
-     */
-    public static synchronized void removeTrace(final CtfTmfTrace trace) {
-        CtfTraceManager mgr = map.remove(trace);
-        if (mgr != null) {
-            mgr.clear();
-        }
-    }
-
-    /**
-     * Get an iterator for a given trace and context.
-     *
-     * @param trace
-     *            the trace
-     * @param ctx
-     *            the context
-     * @return the iterator
-     * @since 2.0
-     */
-    public static synchronized CtfIterator getIterator(final CtfTmfTrace trace,
-            final CtfTmfContext ctx) {
-        return map.get(trace).getIterator(ctx);
-    }
-
-    /**
-     * Remove an iterator for a given trace and context
-     *
-     * @param trace
-     *            the trace
-     * @param ctx
-     *            the context
-     * @since 2.1
-     */
-    public static synchronized void removeIterator(final CtfTmfTrace trace, final CtfTmfContext ctx) {
-        CtfTraceManager traceManager = map.get(trace);
-        if (traceManager != null) {
-            traceManager.removeIterator(ctx);
-        }
-    }
-}
-
-/**
- * A trace manager
+ * A trace iterator manager
  *
  * @author Matthew Khouzam
  */
-class CtfTraceManager {
+class CtfIteratorManager {
     /*
      * Cache size. Under 1023 on linux32 systems. Number of file handles
      * created.
@@ -119,7 +44,7 @@ class CtfTraceManager {
      */
     private final Random fRnd;
 
-    public CtfTraceManager(CtfTmfTrace trace) {
+    public CtfIteratorManager(CtfTmfTrace trace) {
         fMap = new HashMap<>();
         fRandomAccess = new ArrayList<>();
         fRnd = new Random(System.nanoTime());
@@ -226,4 +151,4 @@ class CtfTraceManager {
         fMap.clear();
         fRandomAccess.clear();
     }
-}
+}
\ No newline at end of file
index 5ab11e0ee5812657c14db6d3c7b5bbc16f099616..168417b04162bd3f54b584d80545cbf0810e6899 100644 (file)
@@ -146,7 +146,7 @@ public class CtfTmfContext implements ITmfContext {
 
     @Override
     public void dispose() {
-        CtfIteratorManager.removeIterator(fTrace, this);
+        CtfIteratorCEO.removeIterator(fTrace, this);
     }
 
     /**
@@ -197,6 +197,6 @@ public class CtfTmfContext implements ITmfContext {
      * @return an iterator
      */
     private CtfIterator getIterator() {
-        return CtfIteratorManager.getIterator(fTrace, this);
+        return CtfIteratorCEO.getIterator(fTrace, this);
     }
 }
index f230470faa80cc08890f32d3d3dc38fa185f610d..53403efa802a4d25203cf58af117c15e0dff4f38 100644 (file)
@@ -117,7 +117,7 @@ public class CtfTmfTrace extends TmfTrace
 
         try {
             this.fTrace = new CTFTrace(path);
-            CtfIteratorManager.addTrace(this);
+            CtfIteratorCEO.addTrace(this);
             CtfTmfContext ctx;
             /* Set the start and (current) end times for this trace */
             ctx = (CtfTmfContext) seekEvent(0L);
@@ -134,7 +134,7 @@ public class CtfTmfTrace extends TmfTrace
              * Register every event type. When you call getType, it will
              * register a trace to that type in the TmfEventTypeManager
              */
-            try (CtfIterator iter = CtfIteratorManager.getIterator(this, ctx)) {
+            try (CtfIterator iter = CtfIteratorCEO.getIterator(this, ctx)) {
                 for (IEventDeclaration ied : iter.getEventDeclarations()) {
                     CtfTmfEventType ctfTmfEventType = fContainedEventTypes.get(ied.getName());
                     if (ctfTmfEventType == null) {
@@ -171,7 +171,7 @@ public class CtfTmfTrace extends TmfTrace
 
     @Override
     public synchronized void dispose() {
-        CtfIteratorManager.removeTrace(this);
+        CtfIteratorCEO.removeTrace(this);
         if (fTrace != null) {
             fTrace.close();
             fTrace = null;
@@ -432,7 +432,7 @@ public class CtfTmfTrace extends TmfTrace
     // -------------------------------------------
 
     private static CtfIterator getIterator(CtfTmfTrace trace, CtfTmfContext context) {
-        return CtfIteratorManager.getIterator(trace, context);
+        return CtfIteratorCEO.getIterator(trace, context);
     }
 
     /**
This page took 0.033558 seconds and 5 git commands to generate.