tmf: Make Analysis Requirements implement Predicates
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / analysis / TmfAbstractAnalysisParamProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 É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 */
24 public abstract class TmfAbstractAnalysisParamProvider implements IAnalysisParameterProvider {
25
26 /**
27 * The module registered with this provider
28 */
29 private IAnalysisModule fModule;
30
31 @Override
32 public void registerModule(IAnalysisModule module) {
33 if (module == null) {
34 throw new IllegalArgumentException();
35 }
36 ITmfTrace selectedTrace = TmfTraceManager.getInstance().getActiveTrace();
37 /* If no trace is active, just register the module */
38 if (selectedTrace == null) {
39 fModule = module;
40 return;
41 }
42 IAnalysisModule selectedModule = selectedTrace.getAnalysisModule(module.getId());
43 /* register only if the module is for the currently selected trace */
44 if (selectedModule == module) {
45 fModule = module;
46 }
47 }
48
49 /**
50 * Gets the analysis module
51 *
52 * @return the {@link IAnalysisModule} associated with this provider
53 */
54 protected IAnalysisModule getModule() {
55 return fModule;
56 }
57
58 /**
59 * Notify the registered module that the said parameter has a new value. The
60 * analysis module will decide what to do with this information
61 *
62 * @param name
63 * Name of the modified parameter
64 */
65 protected void notifyParameterChanged(String name) {
66 IAnalysisModule module = fModule;
67 if (module != null && name != null) {
68 module.notifyParameterChanged(name);
69 }
70 }
71 }
This page took 0.030802 seconds and 5 git commands to generate.