837993127526acbc85da22492d7c30c7723c479a
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core.tests / stubs / org / eclipse / tracecompass / analysis / os / linux / core / tests / stubs / trace / TmfXmlKernelTraceStub.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
10 package org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace;
11
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelTidAspect;
14 import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.ThreadPriorityAspect;
15 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
16 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
17 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
18 import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
19
20 import com.google.common.collect.ImmutableSet;
21
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
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
64 }
This page took 0.033193 seconds and 4 git commands to generate.