Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / HistogramRequest.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2011, 2012 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 * William Bourque - Initial API and implementation
11 * Yuriy Vashchuk - Heritage correction.
12 * Francois Chouinard - Cleanup and refactoring
13 * Francois Chouinard - Moved from LTTng to TMF
14 *******************************************************************************/
15
16 package org.eclipse.linuxtools.tmf.ui.views.histogram;
17
18 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
19 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
20 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
21 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
22 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
23
24 /**
25 * Class to request events for given time range from a trace to fill a HistogramDataModel and HistogramView.
26 *
27 * @version 1.0
28 * @author Francois Chouinard
29 * <p>
30 */
31 public class HistogramRequest extends TmfEventRequest {
32
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36
37 /**
38 * The histogram data model to fill.
39 */
40 protected final HistogramDataModel fHistogram;
41
42 // ------------------------------------------------------------------------
43 // Constructor
44 // ------------------------------------------------------------------------
45
46 /**
47 * Constructor
48 *
49 * @param histogram
50 * The histogram data model
51 * @param range
52 * The time range to request data
53 * @param rank
54 * The index of the first event to retrieve
55 * @param nbEvents
56 * The number of events requested
57 * @param blockSize
58 * The number of events per block
59 * @param execType
60 * The requested execution priority
61 *
62 */
63 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
64 int rank, int nbEvents, int blockSize,
65 ITmfDataRequest.ExecutionType execType) {
66 super(ITmfEvent.class, range, rank, nbEvents,
67 (blockSize > 0) ? blockSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE,
68 execType);
69 fHistogram = histogram;
70 }
71
72 // ------------------------------------------------------------------------
73 // TmfEventRequest
74 // ------------------------------------------------------------------------
75
76 /**
77 * Handle the event from the trace by updating the histogram data model.
78 *
79 * @param event a event from the trace
80 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
81 */
82 @Override
83 public void handleData(ITmfEvent event) {
84 super.handleData(event);
85 if (event != null) {
86 long timestamp = event.getTimestamp().normalize(0, -9).getValue();
87 fHistogram.countEvent(getNbRead(), timestamp);
88 }
89 }
90
91 /**
92 * Complete the request. It also notifies the histogram model about the completion.
93 *
94 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
95 */
96 @Override
97 public void handleCompleted() {
98 fHistogram.complete();
99 super.handleCompleted();
100 }
101 }
This page took 0.034217 seconds and 6 git commands to generate.