tmf: Avoid hanging when waiting on a cancelled analysis
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfTraceContext.java
CommitLineData
fc526aef
AM
1/*******************************************************************************
2 * Copyright (c) 2013 Ericsson
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 * Contributors:
10 * Alexandre Montplaisir - Initial API and implementation
0fcf3b09 11 * Patrick Tasse - Support selection range
d3de0920 12 * Xavier Raynaud - Support filters tracking
fc526aef
AM
13 *******************************************************************************/
14
15package org.eclipse.linuxtools.tmf.core.trace;
16
d3de0920 17import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
fc526aef
AM
18import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
19import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
20import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
21
22/**
23 * Context of a trace, which is the representation of the "view" the user
0fcf3b09 24 * currently has on this trace (window time range, selected time or time range).
fc526aef
AM
25 *
26 * TODO could be extended to support the notion of current location too.
27 *
28 * @author Alexandre Montplaisir
29 * @since 2.0
30 */
31final class TmfTraceContext {
32
33 static final TmfTraceContext NULL_CONTEXT =
0fcf3b09 34 new TmfTraceContext(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH, TmfTimeRange.NULL_RANGE);
fc526aef 35
0fcf3b09
PT
36 private final TmfTimeRange fSelection;
37 private final TmfTimeRange fWindowRange;
d3de0920 38 private final ITmfFilter fFilter;
fc526aef 39
0fcf3b09
PT
40 public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr) {
41 fSelection = new TmfTimeRange(beginTs, endTs);
42 fWindowRange = tr;
d3de0920 43 fFilter = null;
fc526aef
AM
44 }
45
0fcf3b09
PT
46 public TmfTraceContext(TmfTraceContext prevCtx, ITmfTimestamp beginTs, ITmfTimestamp endTs) {
47 fSelection = new TmfTimeRange(beginTs, endTs);
48 fWindowRange = prevCtx.fWindowRange;
d3de0920 49 fFilter = prevCtx.fFilter;
fc526aef
AM
50 }
51
0fcf3b09
PT
52 public TmfTraceContext(TmfTraceContext prevCtx, TmfTimeRange tr) {
53 fSelection = prevCtx.fSelection;
54 fWindowRange = tr;
d3de0920
XR
55 fFilter = prevCtx.fFilter;
56 }
57
58 /**
59 * @param prevCtx
60 * The previous context
61 * @param filter
62 * The applied filter
63 * @since 2.2
64 */
65 public TmfTraceContext(TmfTraceContext prevCtx, ITmfFilter filter) {
66 fSelection = prevCtx.fSelection;
67 fWindowRange = prevCtx.fWindowRange;
68 fFilter = filter;
fc526aef
AM
69 }
70
0fcf3b09
PT
71 public ITmfTimestamp getSelectionBegin() {
72 return fSelection.getStartTime();
73 }
74
75 public ITmfTimestamp getSelectionEnd() {
76 return fSelection.getEndTime();
77 }
78
79 public TmfTimeRange getWindowRange() {
80 return fWindowRange;
fc526aef
AM
81 }
82
d3de0920
XR
83 /**
84 * @return the current filter applied to the trace
85 * @since 2.2
86 */
87 public ITmfFilter getFilter() {
88 return fFilter;
89 }
90
fc526aef 91 public boolean isValid() {
0fcf3b09
PT
92 if (fSelection.getStartTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
93 fSelection.getEndTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
94 fWindowRange.getEndTime().compareTo(fWindowRange.getStartTime()) <= 0) {
fc526aef
AM
95 return false;
96 }
97 return true;
98 }
99
100 @Override
101 public String toString() {
0fcf3b09
PT
102 return getClass().getSimpleName() + "[fSelection=" + fSelection + //$NON-NLS-1$
103 ", fWindowRange=" + fWindowRange + ']'; //$NON-NLS-1$
fc526aef
AM
104 }
105}
This page took 0.043152 seconds and 5 git commands to generate.