5e77ed0e26ef0b569c2c668c22d0277d31b9ae4b
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / analysis / os / linux / core / inputoutput / InputOutputAnalysisModule.java
1 /*******************************************************************************
2 * Copyright (c) 2016 É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
10 package org.eclipse.tracecompass.analysis.os.linux.core.inputoutput;
11
12 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
13
14 import java.util.HashSet;
15 import java.util.Set;
16
17 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
18 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
19 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
20 import org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.InputOutputStateProvider;
21 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
22 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
23 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
24 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
25 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
26
27 /**
28 * State System Module for Input Output traces
29 *
30 * @author Houssem Daoud
31 * @since 2.0
32 */
33 public class InputOutputAnalysisModule extends TmfStateSystemAnalysisModule {
34
35 /** The ID of this analysis module */
36 public static final String ID = "org.eclipse.tracecompass.analysis.os.linux.inputoutput"; //$NON-NLS-1$
37
38 @Override
39 protected ITmfStateProvider createStateProvider() {
40 ITmfTrace trace = checkNotNull(getTrace());
41 IKernelAnalysisEventLayout layout;
42
43 if (trace instanceof IKernelTrace) {
44 layout = ((IKernelTrace) trace).getKernelEventLayout();
45 } else {
46 /* Fall-back to the base LttngEventLayout */
47 layout = IKernelAnalysisEventLayout.DEFAULT_LAYOUT;
48 }
49
50 return new InputOutputStateProvider(trace, layout);
51 }
52
53 @Override
54 protected StateSystemBackendType getBackendType() {
55 return StateSystemBackendType.FULL;
56 }
57
58 @Override
59 protected Iterable<IAnalysisModule> getDependentAnalyses() {
60 Set<IAnalysisModule> modules = new HashSet<>();
61
62 ITmfTrace trace = getTrace();
63 if (trace == null) {
64 throw new IllegalStateException();
65 }
66 /*
67 * This analysis depends on the LTTng kernel analysis, so it's added to
68 * dependent modules.
69 */
70 Iterable<KernelAnalysisModule> kernelModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class);
71 for (KernelAnalysisModule kernelModule : kernelModules) {
72 /* Only add the first one we find, if there is one */
73 modules.add(kernelModule);
74 break;
75 }
76 return modules;
77 }
78
79 }
This page took 0.033469 seconds and 4 git commands to generate.