Analysis: Add the active path module
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.graph.core / src / org / eclipse / tracecompass / internal / analysis / graph / core / criticalpath / AlgorithmManager.java
diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/criticalpath/AlgorithmManager.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/internal/analysis/graph/core/criticalpath/AlgorithmManager.java
new file mode 100644 (file)
index 0000000..78504c0
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.graph.core.criticalpath;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.graph.core.criticalpath.ICriticalPathAlgorithm;
+
+/**
+ * Register algorithm
+ *
+ * FIXME: is there already a facility in Eclipse to replace this class?
+ * @author Francis Giraldeau
+ *
+ */
+public final class AlgorithmManager {
+
+    private static @Nullable AlgorithmManager INSTANCE;
+    private final Map<String, Class<? extends ICriticalPathAlgorithm>> map;
+
+    private AlgorithmManager() {
+        map = new HashMap<>();
+    }
+
+    /**
+     * Get the singleton instance
+     *
+     * @return the instance
+     */
+    public static AlgorithmManager getInstance() {
+        AlgorithmManager manager = INSTANCE;
+        if (manager == null) {
+            manager = new AlgorithmManager();
+            manager.register(CriticalPathAlgorithmBounded.class);
+            INSTANCE = manager;
+        }
+        return manager;
+    }
+
+    /**
+     * Register a type in the manager
+     *
+     * @param type the class to register
+     */
+    public void register(Class<? extends ICriticalPathAlgorithm> type) {
+        map.put(type.getSimpleName(), type);
+    }
+
+    /**
+     * Return registered types
+     * @return the types
+     */
+    public Map<String, Class<? extends ICriticalPathAlgorithm>> registeredTypes() {
+        return map;
+    }
+
+}
This page took 0.039897 seconds and 5 git commands to generate.