Merge branch 'master'
[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 * <b><u>HistogramRequest</u></b>
26 * <p>
27 */
28 public class HistogramRequest extends TmfEventRequest<ITmfEvent> {
29
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 protected final HistogramDataModel fHistogram;
35
36 // ------------------------------------------------------------------------
37 // Constructor
38 // ------------------------------------------------------------------------
39
40 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range, int rank, int nbEvents, ITmfDataRequest.ExecutionType execType) {
41 super(ITmfEvent.class, range, rank, nbEvents, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, execType);
42 fHistogram = histogram;
43 }
44
45 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range, ITmfDataRequest.ExecutionType execType) {
46 this(histogram, range, 0, ALL_DATA, execType);
47 }
48
49 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range, int rank, ITmfDataRequest.ExecutionType execType) {
50 this(histogram, range, rank, ALL_DATA, execType);
51 }
52
53 // ------------------------------------------------------------------------
54 // TmfEventRequest
55 // ------------------------------------------------------------------------
56
57 @Override
58 public void handleData(ITmfEvent event) {
59 super.handleData(event);
60 if (event != null) {
61 long timestamp = event.getTimestamp().getValue();
62 fHistogram.countEvent(getNbRead(), timestamp);
63 }
64 }
65
66 @Override
67 public void handleCompleted() {
68 fHistogram.complete();
69 super.handleCompleted();
70 }
71
72 @Override
73 public void handleCancel() {
74 super.handleCancel();
75 }
76
77 }
This page took 0.034568 seconds and 6 git commands to generate.