3e79da82bd3bccb6687f5d78390679d156045a8e
[deliverable/tracecompass.git] / tmf / org.lttng.scope.tmf2.views.core / src / org / lttng / scope / tmf2 / views / core / timegraph / model / provider / statesystem / StateSystemModelArrowProvider.java
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.tmf2.views.core.timegraph.model.provider.statesystem;
11
12 import java.util.concurrent.FutureTask;
13
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
16 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
17 import org.lttng.scope.tmf2.views.core.TimeRange;
18 import org.lttng.scope.tmf2.views.core.timegraph.model.provider.arrows.TimeGraphModelArrowProvider;
19 import org.lttng.scope.tmf2.views.core.timegraph.model.render.arrows.TimeGraphArrowRender;
20 import org.lttng.scope.tmf2.views.core.timegraph.model.render.arrows.TimeGraphArrowSeries;
21 import org.lttng.scope.tmf2.views.core.timegraph.model.render.tree.TimeGraphTreeRender;
22
23 import ca.polymtl.dorsal.libdelorean.ITmfStateSystem;
24
25 /**
26 * Basic implementation of a {@link TimeGraphModelArrowProvider} backed by a
27 * state system.
28 *
29 * @author Alexandre Montplaisir
30 */
31 public abstract class StateSystemModelArrowProvider extends TimeGraphModelArrowProvider {
32
33 private final String fStateSystemModuleId;
34
35 private transient @Nullable ITmfStateSystem fStateSystem = null;
36
37 /**
38 * Constructor
39 *
40 * @param arrowSeries
41 * The arrow series that will be represented by this arrow
42 * provider
43 * @param stateSystemModuleId
44 * The ID of the state system from which the information should
45 * be fetched
46 */
47 public StateSystemModelArrowProvider(TimeGraphArrowSeries arrowSeries,
48 String stateSystemModuleId) {
49 super(arrowSeries);
50 fStateSystemModuleId = stateSystemModuleId;
51
52 /*
53 * Change listener which will take care of keeping the target state
54 * system up to date.
55 */
56 traceProperty().addListener((obs, oldValue, newValue) -> {
57 ITmfTrace trace = newValue;
58 if (trace == null) {
59 fStateSystem = null;
60 return;
61 }
62
63 // FIXME Remove the extra thread once we move to Jabberwocky
64 Thread thread = new Thread(() -> {
65 fStateSystem = TmfStateSystemAnalysisModule.getStateSystem(trace, fStateSystemModuleId);
66 });
67 thread.start();
68 });
69 }
70
71 /**
72 * The state system from which the data should be fetched. This will be kept
73 * in sync with the {@link #traceProperty}.
74 *
75 * @return The target state system. It will be null if the current trace is
76 * null.
77 */
78 protected final @Nullable ITmfStateSystem getStateSystem() {
79 return fStateSystem;
80 }
81
82 @Override
83 public abstract TimeGraphArrowRender getArrowRender(TimeGraphTreeRender treeRender, TimeRange timeRange, @Nullable FutureTask<?> task);
84 }
This page took 0.034624 seconds and 5 git commands to generate.