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
CommitLineData
51480ca2
FG
1/*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10package org.eclipse.tracecompass.internal.analysis.graph.core.criticalpath;
11
12import java.util.HashMap;
13import java.util.Map;
14
15import org.eclipse.jdt.annotation.Nullable;
16import org.eclipse.tracecompass.analysis.graph.core.criticalpath.ICriticalPathAlgorithm;
17
18/**
19 * Register algorithm
20 *
21 * FIXME: is there already a facility in Eclipse to replace this class?
22 * @author Francis Giraldeau
23 *
24 */
25public final class AlgorithmManager {
26
27 private static @Nullable AlgorithmManager INSTANCE;
28 private final Map<String, Class<? extends ICriticalPathAlgorithm>> map;
29
30 private AlgorithmManager() {
31 map = new HashMap<>();
32 }
33
34 /**
35 * Get the singleton instance
36 *
37 * @return the instance
38 */
39 public static AlgorithmManager getInstance() {
40 AlgorithmManager manager = INSTANCE;
41 if (manager == null) {
42 manager = new AlgorithmManager();
43 manager.register(CriticalPathAlgorithmBounded.class);
44 INSTANCE = manager;
45 }
46 return manager;
47 }
48
49 /**
50 * Register a type in the manager
51 *
52 * @param type the class to register
53 */
54 public void register(Class<? extends ICriticalPathAlgorithm> type) {
55 map.put(type.getSimpleName(), type);
56 }
57
58 /**
59 * Return registered types
60 * @return the types
61 */
62 public Map<String, Class<? extends ICriticalPathAlgorithm>> registeredTypes() {
63 return map;
64 }
65
66}
This page took 0.027 seconds and 5 git commands to generate.