Commit | Line | Data |
---|---|---|
af3275f8 AM |
1 | /* |
2 | * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com> | |
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.lttng.scope.lttng.kernel.core.views.timegraph.resources.elements; | |
11 | ||
12 | import java.util.List; | |
13 | import java.util.function.Predicate; | |
14 | ||
15 | import org.eclipse.jdt.annotation.NonNull; | |
16 | import org.eclipse.tracecompass.ctf.tmf.core.event.CtfTmfEvent; | |
17 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
18 | import org.lttng.scope.tmf2.views.core.timegraph.model.provider.statesystem.StateSystemTimeGraphTreeElement; | |
19 | import org.lttng.scope.tmf2.views.core.timegraph.model.render.tree.TimeGraphTreeElement; | |
20 | ||
21 | /** | |
22 | * Element of the Resources time graph which represents a CPU. | |
23 | * | |
24 | * @author Alexandre Montplaisir | |
25 | */ | |
26 | public class ResourcesCpuTreeElement extends StateSystemTimeGraphTreeElement { | |
27 | ||
28 | private final int fCpu; | |
29 | ||
30 | /** | |
31 | * Constructor | |
32 | * | |
33 | * @param cpu | |
34 | * The CPU of this CPU tree element | |
35 | * @param children | |
36 | * The child elements | |
37 | * @param sourceQuark | |
38 | * The corresponding quark (under the "CPUs" sub-tree) in the | |
39 | * state system. | |
40 | */ | |
41 | public ResourcesCpuTreeElement(int cpu, | |
42 | List<TimeGraphTreeElement> children, int sourceQuark) { | |
43 | super(Messages.treeElementPrefixCpu + ' ' + String.valueOf(cpu), | |
44 | children, | |
45 | sourceQuark); | |
46 | ||
47 | fCpu = cpu; | |
48 | } | |
49 | ||
50 | /** | |
51 | * Get the CPU represented by this tree element | |
52 | * | |
53 | * @return The CPU number | |
54 | */ | |
55 | public int getCpu() { | |
56 | return fCpu; | |
57 | } | |
58 | ||
59 | @Override | |
60 | public @NonNull Predicate<ITmfEvent> getEventMatching() { | |
61 | return event -> { | |
62 | // FIXME The notion of CPU should be in the base framework. | |
63 | if (!(event instanceof CtfTmfEvent)) { | |
64 | return false; | |
65 | } | |
66 | CtfTmfEvent ctfEvent = (CtfTmfEvent) event; | |
67 | return (fCpu == ctfEvent.getCPU()); | |
68 | }; | |
69 | } | |
70 | ||
71 | } |