Commit | Line | Data |
---|---|---|
698fde87 GB |
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.tests.stubs.trace; | |
11 | ||
12 | import org.eclipse.jdt.annotation.Nullable; | |
0f7a12d3 AM |
13 | import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelTidAspect; |
14 | import org.eclipse.tracecompass.analysis.os.linux.core.kernel.ThreadPriorityAspect; | |
698fde87 GB |
15 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; |
16 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace; | |
cca845d9 | 17 | import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; |
698fde87 GB |
18 | import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub; |
19 | ||
cca845d9 GB |
20 | import com.google.common.collect.ImmutableSet; |
21 | ||
698fde87 GB |
22 | /** |
23 | * A trace stub that implements a kernel trace. It can add an event layout to | |
24 | * the trace. | |
25 | * | |
26 | * @author Geneviève Bastien | |
27 | */ | |
28 | public class TmfXmlKernelTraceStub extends TmfXmlTraceStub implements IKernelTrace { | |
29 | ||
30 | private @Nullable IKernelAnalysisEventLayout fLayout; | |
31 | ||
32 | @Override | |
33 | public IKernelAnalysisEventLayout getKernelEventLayout() { | |
34 | IKernelAnalysisEventLayout layout = fLayout; | |
35 | if (layout == null) { | |
36 | return KernelEventLayoutStub.getInstance(); | |
37 | } | |
38 | return layout; | |
39 | } | |
40 | ||
41 | /** | |
42 | * Set the kernel event layout to use with this trace | |
43 | * | |
44 | * @param layout | |
45 | * The event layout to use with this trace | |
46 | */ | |
47 | public void setKernelEventLayout(IKernelAnalysisEventLayout layout) { | |
48 | fLayout = layout; | |
49 | } | |
50 | ||
cca845d9 GB |
51 | @Override |
52 | public Iterable<ITmfEventAspect> getEventAspects() { | |
53 | /* | |
54 | * This method needs to fill the aspects dynamically because aspects in | |
55 | * the parent class are not all present at the beginning of the trace | |
56 | */ | |
57 | ImmutableSet.Builder<ITmfEventAspect> builder = ImmutableSet.builder(); | |
58 | builder.addAll(super.getEventAspects()); | |
59 | builder.add(KernelTidAspect.INSTANCE); | |
60 | builder.add(ThreadPriorityAspect.INSTANCE); | |
61 | return builder.build(); | |
62 | } | |
63 | ||
698fde87 | 64 | } |