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 java
.util
.Collection
;
16 import java
.util
.HashSet
;
18 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
19 import org
.eclipse
.jdt
.annotation
.Nullable
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModule
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceUtils
;
25 * This utility class contains some utility methods to retrieve specific traces
26 * or analysis in an experiment.
28 * @author Geneviève Bastien
31 public final class TmfExperimentUtils
{
33 private TmfExperimentUtils() {
37 // ------------------------------------------------------------------------
38 // Utility methods for analysis modules
39 // ------------------------------------------------------------------------
41 private static Iterable
<ITmfTrace
> getTracesFromHost(TmfExperiment experiment
, String hostId
) {
42 Collection
<ITmfTrace
> hostTraces
= new HashSet
<>();
43 for (ITmfTrace trace
: experiment
.getTraces()) {
44 if (trace
.getHostId().equals(hostId
)) {
45 hostTraces
.add(trace
);
52 * Get a specific analysis module from a specific host of an experiment. It
53 * will return the first module with the given ID from the first trace of
54 * the host that has such a module.
57 * The experiment the host belongs to
59 * The ID of the host for which we want the specified analysis
61 * The ID of the requested analysis
62 * @return The requested analysis module or {@code null} if no module found
64 public static @Nullable IAnalysisModule
getAnalysisModuleForHost(TmfExperiment experiment
, String hostId
, String analysisId
) {
65 for (ITmfTrace trace
: getTracesFromHost(experiment
, hostId
)) {
66 IAnalysisModule module
= trace
.getAnalysisModule(analysisId
);
75 * Get an analysis module of a specific class from a specific host of an
76 * experiment. It will return the first module of the given class from the
77 * first trace of the host that has such a module.
80 * The experiment the host belongs to
82 * The ID of the host for which we want the specified analysis
84 * The class of the analysis module to return
85 * @return The first analysis module of the given class or {@code null} if
88 public static @Nullable <T
extends IAnalysisModule
> T
getAnalysisModuleOfClassForHost(TmfExperiment experiment
, String hostId
, Class
<T
> moduleClass
) {
89 for (ITmfTrace trace
: getTracesFromHost(experiment
, hostId
)) {
90 for (T module
: TmfTraceUtils
.getAnalysisModulesOfClass(trace
, moduleClass
)) {
This page took 0.031343 seconds and 5 git commands to generate.