1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.tests
.state
;
15 import java
.util
.HashMap
;
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
;
28 public class StateManagerFactoryTestSupport
{
29 // ========================================================================
31 // =======================================================================
33 private static final Map
<String
, IStateTraceManager
> instanceBook
= new HashMap
<String
, IStateTraceManager
>();
35 // ========================================================================
37 // =======================================================================
40 * Provide a stateManager instance per trace
44 public static IStateTraceManager
getManager(ITmfTrace trace
) {
45 String traceUniqueId
= trace
.getName();
47 if (traceUniqueId
== null) {
51 if (instanceBook
.containsKey(traceUniqueId
)) {
52 return instanceBook
.get(traceUniqueId
);
55 // LttngTraceState traceModel =
56 // StateModelFactory.getStateEntryInstance();
57 IStateTraceManager manager
= null;
59 // catch construction problems
61 LTTngTreeNode parent
= null;
64 manager
= new StateTraceManager(id
, parent
, traceUniqueId
, trace
);
65 } catch (LttngStateException e
) {
69 instanceBook
.put(traceUniqueId
, manager
);
74 * Remove previously registered managers
75 * @param traceUniqueId
77 public static void removeManager(String traceUniqueId
) {
78 if (traceUniqueId
!= null && instanceBook
.containsKey(traceUniqueId
)) {
79 instanceBook
.remove(traceUniqueId
);