1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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
.core
.state
.experiment
;
15 import org
.eclipse
.linuxtools
.lttng
.core
.TraceDebug
;
16 import org
.eclipse
.linuxtools
.lttng
.core
.model
.LTTngTreeNode
;
17 import org
.eclipse
.linuxtools
.lttng
.core
.state
.LttngStateException
;
18 import org
.eclipse
.linuxtools
.lttng
.core
.state
.trace
.IStateTraceManager
;
19 import org
.eclipse
.linuxtools
.lttng
.core
.state
.trace
.StateTraceManager
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.experiment
.TmfExperiment
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
27 public class StateManagerFactory
{
28 // ========================================================================
30 // =======================================================================
32 private static IStateExperimentManager experimentManager
= null;
34 * Allows to modify the check point interval for every new instance of trace manager
36 private static Long ftraceCheckPointInterval
= null;
42 // ========================================================================
44 // =======================================================================
47 * @param traceUniqueId
51 public static LTTngTreeNode
getManager(ITmfTrace rtrace
, LTTngTreeNode experiment
) {
58 String traceUniqueId
= rtrace
.getName();
59 if (traceUniqueId
== null) {
63 LTTngTreeNode managerNode
= null;
64 managerNode
= experiment
.getChildByName(traceUniqueId
);
66 if (managerNode
!= null && managerNode
instanceof IStateTraceManager
) {
70 // LttngTraceState traceModel =
71 // StateModelFactory.getStateEntryInstance();
72 StateTraceManager manager
= null;
74 // catch potential construction problems
76 manager
= new StateTraceManager(experiment
.getNextUniqueId(), experiment
, traceUniqueId
, rtrace
);
78 // Allow the possibility to configure the trace state check point
79 // interval at creation time
80 if (ftraceCheckPointInterval
!= null) {
81 manager
.setCheckPointInterval(ftraceCheckPointInterval
);
84 } catch (LttngStateException e
) {
88 experiment
.addChild(manager
);
93 * Provide the State trace set manager
97 public static IStateExperimentManager
getExperimentManager() {
98 return experimentManager
;
102 * Remove previously registered managers
104 * @param traceUniqueId
106 public static void removeManager(ITmfTrace rtrace
, LTTngTreeNode rexperiment
) {
107 if (rtrace
!= null && rexperiment
!= null && rexperiment
.getValue() instanceof TmfExperiment
<?
>) {
108 LTTngTreeNode childToremove
= rexperiment
.getChildByName(rtrace
.getName());
109 if (childToremove
!= null) {
110 rexperiment
.removeChild(childToremove
);
113 TraceDebug
.debug("Invalid arguments to remove manager for trace: " //$NON-NLS-1$
119 * initialization of factory
121 private static void initCheck() {
122 if (experimentManager
== null) {
123 Long id
= 0L; // unique id
124 String name
= "StateExperimentManager"; // name //$NON-NLS-1$
125 experimentManager
= new StateExperimentManager(id
, name
);
132 public static void dispose() {
133 if (experimentManager
!= null) {
134 experimentManager
= null;
139 * @return the traceCheckPointInterval
141 public static Long
getTraceCheckPointInterval() {
142 return ftraceCheckPointInterval
;
146 * @param traceCheckPointInterval
147 * the traceCheckPointInterval to set
149 public static void setTraceCheckPointInterval(Long traceCheckPointInterval
) {
150 StateManagerFactory
.ftraceCheckPointInterval
= traceCheckPointInterval
;