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 | |
b63291e6 GB |
22 | */ |
23 | public class TmfNewAnalysisOutputListener implements ITmfNewAnalysisModuleListener { | |
24 | ||
25 | private final String fAnalysisId; | |
26 | private final Class<? extends IAnalysisModule> fAnalysisModuleClass; | |
ba27dd38 | 27 | private final @NonNull IAnalysisOutput fOutput; |
b63291e6 GB |
28 | |
29 | /** | |
30 | * Constructor | |
31 | * | |
32 | * @param output | |
33 | * The analysis output to add if the analysis corresponds to the | |
34 | * ID or class | |
35 | * @param analysisId | |
36 | * The analysis ID of the single analysis to match | |
37 | * @param moduleClass | |
38 | * The module class this output applies to | |
39 | */ | |
ba27dd38 | 40 | public TmfNewAnalysisOutputListener(@NonNull IAnalysisOutput output, String analysisId, Class<? extends IAnalysisModule> moduleClass) { |
b63291e6 GB |
41 | fOutput = output; |
42 | fAnalysisId = analysisId; | |
43 | fAnalysisModuleClass = moduleClass; | |
44 | } | |
45 | ||
46 | @Override | |
47 | public void moduleCreated(IAnalysisModule module) { | |
48 | if (fAnalysisId != null) { | |
49 | if (module.getId().equals(fAnalysisId)) { | |
50 | module.registerOutput(fOutput); | |
51 | } | |
52 | } else if (fAnalysisModuleClass != null) { | |
53 | if (fAnalysisModuleClass.isAssignableFrom(module.getClass())) { | |
54 | module.registerOutput(fOutput); | |
55 | } | |
56 | } | |
57 | } | |
58 | ||
59 | } |