368df8398979e5a8a4c62ae705bf78f1de3b6ac1
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / analysis / TmfAbstractAnalysisParamProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
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 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.core.analysis;
14
15 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
16 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
17
18 /**
19 * Abstract class for parameter providers, implements methods and
20 * functionalities to warn the analysis module of parameter changed
21 *
22 * @author Geneviève Bastien
23 * @since 3.0
24 */
25 public abstract class TmfAbstractAnalysisParamProvider implements IAnalysisParameterProvider {
26
27 /**
28 * The module registered with this provider
29 */
30 private IAnalysisModule fModule;
31
32 @Override
33 public void registerModule(IAnalysisModule module) {
34 if (module == null) {
35 throw new IllegalArgumentException();
36 }
37 ITmfTrace selectedTrace = TmfTraceManager.getInstance().getActiveTrace();
38 /* If no trace is active, just register the module */
39 if (selectedTrace == null) {
40 fModule = module;
41 return;
42 }
43 IAnalysisModule selectedModule = selectedTrace.getAnalysisModule(module.getId());
44 /* register only if the module is for the currently selected trace */
45 if (selectedModule == module) {
46 fModule = module;
47 }
48 }
49
50 /**
51 * Gets the analysis module
52 *
53 * @return the {@link IAnalysisModule} associated with this provider
54 */
55 protected IAnalysisModule getModule() {
56 return fModule;
57 }
58
59 /**
60 * Notify the registered module that the said parameter has a new value. The
61 * analysis module will decide what to do with this information
62 *
63 * @param name
64 * Name of the modified parameter
65 */
66 protected void notifyParameterChanged(String name) {
67 if (fModule != null) {
68 fModule.notifyParameterChanged(name);
69 }
70 }
71 }
This page took 0.032516 seconds and 4 git commands to generate.