| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2010 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 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | package org.eclipse.linuxtools.lttng.request; |
| 13 | |
| 14 | import org.eclipse.linuxtools.lttng.event.LttngEvent; |
| 15 | import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; |
| 16 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; |
| 17 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; |
| 18 | import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; |
| 19 | import org.eclipse.linuxtools.tmf.request.TmfEventRequest; |
| 20 | |
| 21 | /** |
| 22 | * This class is an extension of Tmf Event Request which includes specific |
| 23 | * references i.e. a status listener to indicate the start and end of the |
| 24 | * request |
| 25 | * |
| 26 | * @author alvaro |
| 27 | * |
| 28 | */ |
| 29 | public abstract class LttngBaseEventRequest extends TmfEventRequest<LttngEvent> { |
| 30 | |
| 31 | // ======================================================================== |
| 32 | // Data |
| 33 | // ======================================================================= |
| 34 | private long numOfEvents = 0; |
| 35 | private boolean clearDataInd = false; |
| 36 | private final LttngTraceState ftraceModel; |
| 37 | /** |
| 38 | * The time to send events to the application as requested, Note: The start |
| 39 | * time of the request for base events is adjusted to the nearest check |
| 40 | * point |
| 41 | */ |
| 42 | private final TmfTimestamp fDispatchTime; |
| 43 | |
| 44 | // ======================================================================== |
| 45 | // Constructors |
| 46 | // ======================================================================= |
| 47 | /** |
| 48 | * @param range |
| 49 | * @param dispatchTime |
| 50 | * @param offset |
| 51 | * @param nbEvents |
| 52 | * @param maxBlockSize |
| 53 | * @param traceModel |
| 54 | * @param listener |
| 55 | */ |
| 56 | public LttngBaseEventRequest(TmfTimeRange range, TmfTimestamp dispatchTime, |
| 57 | long offset, int nbEvents, int maxBlockSize, |
| 58 | LttngTraceState traceModel) { |
| 59 | super(LttngEvent.class, range, nbEvents, maxBlockSize); |
| 60 | ftraceModel = traceModel; |
| 61 | fDispatchTime = dispatchTime; |
| 62 | } |
| 63 | |
| 64 | // ======================================================================== |
| 65 | // Methods |
| 66 | // ======================================================================= |
| 67 | |
| 68 | /** |
| 69 | * Trigger the start to process this request right after the notification to |
| 70 | * the interested listeners |
| 71 | * |
| 72 | * @param experiment |
| 73 | * @param broadcast |
| 74 | * true: All views, false: only to registered listeners |
| 75 | */ |
| 76 | public void startRequestInd(TmfExperiment<LttngEvent> experiment, |
| 77 | boolean broadcast) { |
| 78 | // trigger the start to process this request |
| 79 | experiment.sendRequest(this); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * @param numOfEvents |
| 84 | * the numOfEvents to set |
| 85 | */ |
| 86 | public void setNumOfEvents(long numOfEvents) { |
| 87 | this.numOfEvents = numOfEvents; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @return the numOfEvents |
| 92 | */ |
| 93 | public long getNumOfEvents() { |
| 94 | return numOfEvents; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @param clearAllData |
| 99 | * indicates the need to clear all previous data e.g. a new |
| 100 | * experiment selection |
| 101 | */ |
| 102 | public void setclearDataInd(boolean clearAllData) { |
| 103 | this.clearDataInd = clearAllData; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Returns indication - clearing of all existing data model is required e.g |
| 108 | * from the selection of a new experiment |
| 109 | * |
| 110 | * @return |
| 111 | */ |
| 112 | public boolean isclearDataInd() { |
| 113 | return clearDataInd; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @return the ftraceModel, Trace state-data-model associated to this event |
| 118 | */ |
| 119 | public LttngTraceState getTraceModel() { |
| 120 | return ftraceModel; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * @return The time to start dispatching events to the application |
| 125 | */ |
| 126 | public TmfTimestamp getDispatchTime() { |
| 127 | return fDispatchTime; |
| 128 | } |
| 129 | } |