Rename xxx.lttng to xxx.lttng.core
[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.model.LTTngTreeNode;
19 import org.eclipse.linuxtools.lttng.state.LttngStateException;
20 import org.eclipse.linuxtools.lttng.state.trace.IStateTraceManager;
21 import org.eclipse.linuxtools.lttng.state.trace.StateTraceManager;
22 import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
23
24 /**
25 * @author alvaro
26 *
27 */
28 public class StateManagerFactoryTestSupport {
29 // ========================================================================
30 // Data
31 // =======================================================================
32
33 private static final Map<String, IStateTraceManager> instanceBook = new HashMap<String, IStateTraceManager>();
34
35 // ========================================================================
36 // Methods
37 // =======================================================================
38
39 /**
40 * Provide a stateManager instance per trace
41 *
42 * @return
43 */
44 public static IStateTraceManager getManager(ITmfTrace trace) {
45 String traceUniqueId = trace.getName();
46
47 if (traceUniqueId == null) {
48 return null;
49 }
50
51 if (instanceBook.containsKey(traceUniqueId)) {
52 return instanceBook.get(traceUniqueId);
53 }
54
55 // LttngTraceState traceModel =
56 // StateModelFactory.getStateEntryInstance();
57 IStateTraceManager manager = null;
58
59 // catch construction problems
60 Long id = 0L;
61 LTTngTreeNode parent = null;
62
63 try {
64 manager = new StateTraceManager(id, parent, traceUniqueId, trace);
65 } catch (LttngStateException e) {
66 e.printStackTrace();
67 }
68
69 instanceBook.put(traceUniqueId, manager);
70 return manager;
71 }
72
73 /**
74 * Remove previously registered managers
75 * @param traceUniqueId
76 */
77 public static void removeManager(String traceUniqueId) {
78 if (traceUniqueId != null && instanceBook.containsKey(traceUniqueId)) {
79 instanceBook.remove(traceUniqueId);
80 }
81 }
82
83 }
This page took 0.036656 seconds and 5 git commands to generate.