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; | |
11 | ||
12 | import java.util.Comparator; | |
13 | import java.util.function.Function; | |
14 | import java.util.function.Supplier; | |
15 | ||
16 | import org.lttng.scope.lttng.kernel.core.analysis.os.KernelAnalysisModule; | |
17 | import org.lttng.scope.lttng.kernel.core.views.timegraph.resources.elements.ResourcesIrqTreeElement; | |
18 | import org.lttng.scope.lttng.kernel.core.views.timegraph.resources.elements.ResourcesIrqTreeElement.IrqType; | |
19 | import org.lttng.scope.tmf2.views.core.timegraph.model.provider.states.ITimeGraphModelStateProvider; | |
20 | import org.lttng.scope.tmf2.views.core.timegraph.model.provider.statesystem.StateSystemModelProvider; | |
21 | import org.lttng.scope.tmf2.views.core.timegraph.model.render.tree.TimeGraphTreeRender; | |
22 | ||
23 | /** | |
24 | * Base class for Resources (for now, CPUs and IRQs) model providers. | |
25 | * | |
26 | * Implementations of this class can define the hierarchy the resources are to | |
27 | * be presented in, for example CPUs/IRQs or IRQs/CPUs. | |
28 | * | |
29 | * @author Alexandre Montplaisir | |
30 | */ | |
31 | public abstract class ResourcesBaseModelProvider extends StateSystemModelProvider { | |
32 | ||
33 | private static final Supplier<ITimeGraphModelStateProvider> STATE_PROVIDER = () -> { | |
34 | return new ResourcesModelStateProvider(); | |
35 | }; | |
36 | ||
37 | /** | |
38 | * Comparator to sort IRQ entries in the tree model. | |
39 | * | |
40 | * Shows (hardware) IRQs first, followed by Soft IRQs. Within each section they | |
41 | * are sorted by numerical (not String!) value of their IRQ number. | |
42 | */ | |
43 | protected static final Comparator<ResourcesIrqTreeElement> IRQ_SORTER = Comparator | |
44 | .<ResourcesIrqTreeElement, IrqType> comparing(treeElem -> treeElem.getIrqType()) | |
45 | .thenComparingInt(treeElem -> treeElem.getIrqNumber()); | |
46 | ||
47 | /** | |
48 | * Constructor | |
49 | * | |
50 | * @param providerName | |
51 | * Name of this provider | |
52 | * @param treeRenderFunction | |
53 | * Function to generate a tree render from a given tree context | |
54 | */ | |
55 | public ResourcesBaseModelProvider(String providerName, Function<TreeRenderContext, TimeGraphTreeRender> treeRenderFunction) { | |
56 | super(providerName, | |
57 | null, | |
58 | null, | |
59 | STATE_PROVIDER.get(), | |
60 | null, | |
61 | /* Parameters specific to state system render providers */ | |
62 | KernelAnalysisModule.ID, | |
63 | treeRenderFunction); | |
64 | } | |
65 | ||
66 | } |