dd6e5f3ae176f8fe4847033592beb0dc7d886eeb
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core / src / org / eclipse / tracecompass / internal / tmf / analysis / xml / core / pattern / stateprovider / XmlPatternLatencyStatisticsAnalysis.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 package org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider;
10
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider;
14 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
15 import org.eclipse.tracecompass.segmentstore.core.ISegment;
16 import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlPatternSegmentBuilder;
17 import org.eclipse.tracecompass.tmf.analysis.xml.core.segment.TmfXmlPatternSegment;
18 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
19 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
20
21 /**
22 * Statistic analysis for segments generated by a pattern analysis
23 *
24 * @author Jean-Christian Kouame
25 */
26 public class XmlPatternLatencyStatisticsAnalysis extends AbstractSegmentStatisticsAnalysis {
27
28 private final @Nullable String fPatternAnalysisId;
29
30 /**
31 * Constructor
32 *
33 * @param patternAnalysisId
34 * The pattern analysis ID
35 */
36 public XmlPatternLatencyStatisticsAnalysis(@Nullable String patternAnalysisId) {
37 fPatternAnalysisId = patternAnalysisId;
38 }
39
40 @Override
41 protected @Nullable String getSegmentType(@NonNull ISegment segment) {
42 if (segment instanceof TmfXmlPatternSegment) {
43 TmfXmlPatternSegment patternSegment = (TmfXmlPatternSegment) segment;
44 return patternSegment.getName().substring(TmfXmlPatternSegmentBuilder.PATTERN_SEGMENT_NAME_PREFIX.length());
45 }
46 return null;
47 }
48
49 @Override
50 protected @Nullable ISegmentStoreProvider getSegmentProviderAnalysis(@NonNull ITmfTrace trace) {
51 return fPatternAnalysisId != null ? TmfTraceUtils.getAnalysisModuleOfClass(trace, XmlPatternAnalysis.class, fPatternAnalysisId) : null;
52 }
53 }
This page took 0.033693 seconds and 4 git commands to generate.