temporary re-factoring project
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.tests / src / org / eclipse / linuxtools / lttng / tests / state / StateManagerFactoryTestSupport.java
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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 * Contributors:
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng.tests.state;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.eclipse.linuxtools.lttng.state.StateManager;
19 import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
20 import org.eclipse.linuxtools.lttng.state.model.StateModelFactory;
21
22 /**
23 * @author alvaro
24 *
25 */
26 public class StateManagerFactoryTestSupport {
27 // ========================================================================
28 // Data
29 // =======================================================================
30
31 private static final Map<String, StateManager> instanceBook = new HashMap<String, StateManager>();
32
33 // ========================================================================
34 // Methods
35 // =======================================================================
36
37 /**
38 * Provide a stateManager instance per trace
39 *
40 * @return
41 */
42 public static StateManager getManager(String traceUniqueId) {
43 if (traceUniqueId == null) {
44 return null;
45 }
46
47 if (instanceBook.containsKey(traceUniqueId)) {
48 return instanceBook.get(traceUniqueId);
49 }
50
51 LttngTraceState traceModel = StateModelFactory.getStateEntryInstance();
52 StateStacksHandlerTestSupport stateInputHandler = new StateStacksHandlerTestSupport(traceModel);
53 StateManager manager = new StateManager(stateInputHandler);
54
55 instanceBook.put(traceUniqueId, manager);
56 return manager;
57 }
58
59 /**
60 * Remove previously registered managers
61 * @param traceUniqueId
62 */
63 public static void removeManager(String traceUniqueId) {
64 if (traceUniqueId != null && instanceBook.containsKey(traceUniqueId)) {
65 instanceBook.remove(traceUniqueId);
66 }
67 }
68
69 }
This page took 0.032398 seconds and 6 git commands to generate.