1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
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
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.trace
.experiment
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import java
.util
.Collection
;
18 import java
.util
.HashSet
;
20 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
21 import org
.eclipse
.jdt
.annotation
.Nullable
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModule
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceUtils
;
27 * This utility class contains some utility methods to retrieve specific traces
28 * or analysis in an experiment.
30 * @author Geneviève Bastien
33 public final class TmfExperimentUtils
{
35 private TmfExperimentUtils() {
39 // ------------------------------------------------------------------------
40 // Utility methods for analysis modules
41 // ------------------------------------------------------------------------
43 private static Iterable
<ITmfTrace
> getTracesFromHost(TmfExperiment experiment
, String hostId
) {
44 Collection
<ITmfTrace
> hostTraces
= new HashSet
<>();
45 for (ITmfTrace trace
: experiment
.getTraces()) {
46 if (trace
.getHostId().equals(hostId
)) {
47 hostTraces
.add(trace
);
54 * Get a specific analysis module from a specific host of an experiment. It
55 * will return the first module with the given ID from the first trace of
56 * the host that has such a module.
59 * The experiment the host belongs to
61 * The ID of the host for which we want the specified analysis
63 * The ID of the requested analysis
64 * @return The requested analysis module or {@code null} if no module found
66 public static @Nullable IAnalysisModule
getAnalysisModuleForHost(TmfExperiment experiment
, String hostId
, String analysisId
) {
67 for (ITmfTrace trace
: getTracesFromHost(experiment
, hostId
)) {
68 IAnalysisModule module
= trace
.getAnalysisModule(analysisId
);
77 * Get an analysis module of a specific class from a specific host of an
78 * experiment. It will return the first module of the given class from the
79 * first trace of the host that has such a module.
82 * The experiment the host belongs to
84 * The ID of the host for which we want the specified analysis
86 * The class of the analysis module to return
87 * @return The first analysis module of the given class or {@code null} if
90 public static @Nullable <T
extends IAnalysisModule
> T
getAnalysisModuleOfClassForHost(TmfExperiment experiment
, String hostId
, Class
<T
> moduleClass
) {
91 for (ITmfTrace trace
: getTracesFromHost(experiment
, hostId
)) {
92 trace
= checkNotNull(trace
);
93 for (T module
: TmfTraceUtils
.getAnalysisModulesOfClass(trace
, moduleClass
)) {
This page took 0.032428 seconds and 5 git commands to generate.