ctf: Update paths in the CTF-Testsuite tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / HistogramRequest.java
CommitLineData
378e7718 1/*******************************************************************************
c8422608 2 * Copyright (c) 2009, 2013 Ericsson
20ff3b75 3 *
378e7718
WB
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
20ff3b75 8 *
378e7718
WB
9 * Contributors:
10 * William Bourque - Initial API and implementation
c392540b
FC
11 * Yuriy Vashchuk - Heritage correction.
12 * Francois Chouinard - Cleanup and refactoring
e0752744 13 * Francois Chouinard - Moved from LTTng to TMF
95aa81ef 14 * Simon Delisle - Added a new parameter to the constructor
378e7718 15 *******************************************************************************/
c392540b 16
e0752744 17package org.eclipse.linuxtools.tmf.ui.views.histogram;
6e512b93 18
e0752744 19import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
95aa81ef 20import org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent;
6c13869b
FC
21import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
22import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
3bd46eef
AM
23import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
24import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
6e512b93 25
378e7718 26/**
95aa81ef
JCK
27 * Class to request events for given time range from a trace to fill a
28 * HistogramDataModel and HistogramView.
20ff3b75 29 *
b544077e
BH
30 * @version 1.0
31 * @author Francois Chouinard
95aa81ef 32 * <p>
378e7718 33 */
6256d8ad 34public class HistogramRequest extends TmfEventRequest {
c392540b
FC
35
36 // ------------------------------------------------------------------------
37 // Attributes
38 // ------------------------------------------------------------------------
39
b544077e
BH
40 /**
41 * The histogram data model to fill.
42 */
fbd124dd 43 protected final HistogramDataModel fHistogram;
c392540b 44
95aa81ef
JCK
45 private final boolean fFullRange;
46
c392540b
FC
47 // ------------------------------------------------------------------------
48 // Constructor
49 // ------------------------------------------------------------------------
50
b544077e
BH
51 /**
52 * Constructor
20ff3b75
AM
53 *
54 * @param histogram
55 * The histogram data model
56 * @param range
57 * The time range to request data
58 * @param rank
59 * The index of the first event to retrieve
60 * @param nbEvents
61 * The number of events requested
62 * @param blockSize
63 * The number of events per block
64 * @param execType
65 * The requested execution priority
3bd46eef 66 * @since 2.0
20ff3b75 67 *
b544077e 68 */
95aa81ef 69 @Deprecated
20ff3b75
AM
70 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
71 int rank, int nbEvents, int blockSize,
72 ITmfDataRequest.ExecutionType execType) {
672a642a 73 super(ITmfEvent.class, range, rank, nbEvents, execType);
c392540b 74 fHistogram = histogram;
95aa81ef
JCK
75 if (execType == ExecutionType.FOREGROUND) {
76 fFullRange = false;
77 } else {
78 fFullRange = true;
79 }
80 }
81
82 /**
83 * Constructor
84 *
85 * @param histogram
86 * The histogram data model
87 * @param range
88 * The time range to request data
89 * @param rank
90 * The index of the first event to retrieve
91 * @param nbEvents
92 * The number of events requested
93 * @param blockSize
94 * The number of events per block
95 * @param execType
96 * The requested execution priority
97 * @param fullRange
98 * Full range or time range for histogram request
46a59db7 99 * @since 2.2
95aa81ef
JCK
100 *
101 */
102 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
103 int rank, int nbEvents, int blockSize,
104 ITmfDataRequest.ExecutionType execType, boolean fullRange) {
5cc0453a 105 super(ITmfEvent.class, range, rank, nbEvents, execType);
95aa81ef
JCK
106 fHistogram = histogram;
107 fFullRange = fullRange;
c392540b
FC
108 }
109
c392540b
FC
110 // ------------------------------------------------------------------------
111 // TmfEventRequest
112 // ------------------------------------------------------------------------
20ff3b75 113
b544077e
BH
114 /**
115 * Handle the event from the trace by updating the histogram data model.
20ff3b75 116 *
95aa81ef
JCK
117 * @param event
118 * a event from the trace
b544077e
BH
119 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
120 */
c392540b 121 @Override
e0752744 122 public void handleData(ITmfEvent event) {
c392540b 123 super.handleData(event);
cb866e08 124 if (event != null) {
95aa81ef
JCK
125 if (event instanceof ITmfLostEvent) {
126 ITmfLostEvent lostEvents = (ITmfLostEvent) event;
127 /* clear the old data when it is a new request */
128 fHistogram.countLostEvent(lostEvents.getTimeRange(), lostEvents.getNbLostEvents(), fFullRange);
129
130 } else { /* handle lost event */
131 long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
132 fHistogram.countEvent(getNbRead(), timestamp);
133 }
7ef9ae3f 134 }
6e512b93 135 }
c392540b 136
b544077e 137 /**
95aa81ef
JCK
138 * Complete the request. It also notifies the histogram model about the
139 * completion.
20ff3b75 140 *
b544077e
BH
141 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
142 */
6e512b93 143 @Override
5419a136 144 public void handleCompleted() {
fbd124dd 145 fHistogram.complete();
c392540b 146 super.handleCompleted();
6e512b93 147 }
6e512b93 148}
This page took 0.054988 seconds and 5 git commands to generate.