blob: 7f56b5d2211dae91b8490c0b8c2812e87184d0a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*******************************************************************************
* Copyright (c) 2013 École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Geneviève Bastien - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.analysis;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
/**
* Abstract class for parameter providers, implements methods and
* functionalities to warn the analysis module of parameter changed
*
* @author Geneviève Bastien
* @since 3.0
*/
public abstract class TmfAbstractAnalysisParamProvider implements IAnalysisParameterProvider {
/**
* The module registered with this provider
*/
private IAnalysisModule fModule;
@Override
public void registerModule(IAnalysisModule module) {
if (module == null) {
throw new IllegalArgumentException();
}
ITmfTrace selectedTrace = TmfTraceManager.getInstance().getActiveTrace();
/* If no trace is active, just register the module */
if (selectedTrace == null) {
fModule = module;
return;
}
IAnalysisModule selectedModule = selectedTrace.getAnalysisModule(module.getId());
/* register only if the module is for the currently selected trace */
if (selectedModule == module) {
fModule = module;
}
}
/**
* Gets the analysis module
*
* @return the {@link IAnalysisModule} associated with this provider
*/
protected IAnalysisModule getModule() {
return fModule;
}
/**
* Notify the registered module that the said parameter has a new value. The
* analysis module will decide what to do with this information
*
* @param name
* Name of the modified parameter
*/
protected void notifyParameterChanged(String name) {
if (fModule != null) {
fModule.notifyParameterChanged(name);
}
}
}
|