1 /*******************************************************************************
2 * Copyright (c) 2016 É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
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
;
14 import org
.eclipse
.jdt
.annotation
.Nullable
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.requirements
.TmfAnalysisEventRequirement
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.requirements
.TmfAbstractAnalysisRequirement
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.requirements
.TmfAbstractAnalysisRequirement
.PriorityLevel
;
19 import com
.google
.common
.collect
.ImmutableList
.Builder
;
22 * This class is a pre-requirement class who will instanciate at runtime the
23 * actual requirements depending on a trace's event layout
25 * @author Geneviève Bastien
28 public class KernelEventLayoutRequirement
{
31 * Functional interface that maps a layout to an event name
34 public interface ILayoutToEventName
{
36 * This method will return the event name mapped by this requirement
37 * from the layout. The returned event name may be <code>null</code> in
41 * The event layout of the trace
42 * @return The event name
44 @Nullable String
getEventName(IKernelAnalysisEventLayout layout
);
47 private final Set
<ILayoutToEventName
> fEventNames
;
48 private final PriorityLevel fLevel
;
54 * The layout mappings this requirement represents
56 * Whether the requirement represented by these mapping is
57 * mandatory or optional
59 public KernelEventLayoutRequirement(Set
<ILayoutToEventName
> layoutReqs
, PriorityLevel level
) {
60 fEventNames
= layoutReqs
;
65 * Build a real requirement from the layout mapping to be matched with a
69 * The event layout from which to build the requirements.
70 * @return The real requirement
72 public TmfAbstractAnalysisRequirement
instanciateRequirements(IKernelAnalysisEventLayout layout
) {
73 Builder
<String
> events
= new Builder
<>();
74 for (ILayoutToEventName eventNameLayout
: fEventNames
) {
75 String eventName
= eventNameLayout
.getEventName(layout
);
76 if (eventName
!= null) {
77 events
.add(eventName
);
80 return new TmfAnalysisEventRequirement(events
.build(), fLevel
);