Commit | Line | Data |
---|---|---|
b63291e6 GB |
1 | /******************************************************************************* |
2 | * Copyright (c) 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 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.core.analysis; |
b63291e6 | 14 | |
ba27dd38 GB |
15 | import org.eclipse.jdt.annotation.NonNull; |
16 | ||
b63291e6 GB |
17 | /** |
18 | * This class listens when new analysis modules are created and registers an | |
19 | * output if the module corresponds to the output specifications | |
20 | * | |
21 | * @author Geneviève Bastien | |
22 | * @since 3.0 | |
23 | */ | |
24 | public class TmfNewAnalysisOutputListener implements ITmfNewAnalysisModuleListener { | |
25 | ||
26 | private final String fAnalysisId; | |
27 | private final Class<? extends IAnalysisModule> fAnalysisModuleClass; | |
ba27dd38 | 28 | private final @NonNull IAnalysisOutput fOutput; |
b63291e6 GB |
29 | |
30 | /** | |
31 | * Constructor | |
32 | * | |
33 | * @param output | |
34 | * The analysis output to add if the analysis corresponds to the | |
35 | * ID or class | |
36 | * @param analysisId | |
37 | * The analysis ID of the single analysis to match | |
38 | * @param moduleClass | |
39 | * The module class this output applies to | |
40 | */ | |
ba27dd38 | 41 | public TmfNewAnalysisOutputListener(@NonNull IAnalysisOutput output, String analysisId, Class<? extends IAnalysisModule> moduleClass) { |
b63291e6 GB |
42 | fOutput = output; |
43 | fAnalysisId = analysisId; | |
44 | fAnalysisModuleClass = moduleClass; | |
45 | } | |
46 | ||
47 | @Override | |
48 | public void moduleCreated(IAnalysisModule module) { | |
49 | if (fAnalysisId != null) { | |
50 | if (module.getId().equals(fAnalysisId)) { | |
51 | module.registerOutput(fOutput); | |
52 | } | |
53 | } else if (fAnalysisModuleClass != null) { | |
54 | if (fAnalysisModuleClass.isAssignableFrom(module.getClass())) { | |
55 | module.registerOutput(fOutput); | |
56 | } | |
57 | } | |
58 | } | |
59 | ||
60 | } |