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