2b88329570eabb9bade5ffd75ecc725bf35c8357
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / histogram / HistogramRequest.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2011 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 *******************************************************************************/
14
15 package org.eclipse.linuxtools.lttng.ui.views.histogram;
16
17 import org.eclipse.linuxtools.lttng.core.LttngConstants;
18 import org.eclipse.linuxtools.lttng.core.event.LttngEvent;
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
23 /**
24 * <b><u>HistogramRequest</u></b>
25 * <p>
26 */
27 public class HistogramRequest extends TmfEventRequest<LttngEvent> {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32
33 private final Histogram fHistogram;
34
35 // ------------------------------------------------------------------------
36 // Constructor
37 // ------------------------------------------------------------------------
38
39 public HistogramRequest(Histogram histogram, TmfTimeRange range, int rank, int nbEvents, ITmfDataRequest.ExecutionType execType) {
40 super(LttngEvent.class, range, rank, nbEvents, LttngConstants.DEFAULT_BLOCK_SIZE, execType);
41 fHistogram = histogram;
42 }
43
44 public HistogramRequest(Histogram histogram, TmfTimeRange range, ITmfDataRequest.ExecutionType execType) {
45 this(histogram, range, 0, ALL_DATA, execType);
46 }
47
48 public HistogramRequest(Histogram histogram, TmfTimeRange range, int rank, ITmfDataRequest.ExecutionType execType) {
49 this(histogram, range, rank, ALL_DATA, execType);
50 }
51
52 // ------------------------------------------------------------------------
53 // TmfEventRequest
54 // ------------------------------------------------------------------------
55
56 @Override
57 public void handleData(LttngEvent event) {
58 super.handleData(event);
59 if (event != null) {
60 long timestamp = event.getTimestamp().getValue();
61 fHistogram.countEvent(timestamp);
62 }
63 }
64
65 @Override
66 public void handleCompleted() {
67 fHistogram.refresh();
68 super.handleCompleted();
69 }
70
71 @Override
72 public void handleCancel() {
73 fHistogram.refresh();
74 super.handleCancel();
75 }
76
77 }
This page took 0.031718 seconds and 5 git commands to generate.