[Bug 303523] LTTng/TMF udpates:
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / state / StateDataRequest.java
CommitLineData
5d10d135
ASL
1/*******************************************************************************
2 * Copyright (c) 2009 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 *******************************************************************************/
12package org.eclipse.linuxtools.lttng.state;
13
88144d4a
ASL
14import java.util.Vector;
15
e31e01e8 16import org.eclipse.linuxtools.lttng.event.LttngEvent;
88144d4a 17import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
e31e01e8
FC
18import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
19import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
88144d4a 20import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
5d10d135
ASL
21
22/**
23 * This class is an extension of Data Request which includes specific references
24 * i.e. a status listener to indicate the start and end of the request
25 *
26 * @author alvaro
27 *
28 */
e31e01e8
FC
29public class StateDataRequest extends TmfEventRequest<LttngEvent> {
30
5d10d135 31 // ========================================================================
88144d4a 32 // Data
5d10d135 33 // =======================================================================
88144d4a
ASL
34 private Vector<IStateDataRequestListener> listeners = new Vector<IStateDataRequestListener>();
35 private String transactionId = ""; /* optional user's attribute */
36 private StateManager manager = null;
37 private long numOfEvents = 0;
38 private boolean broadcast = false;
d712a5f3 39 private boolean clearDataInd = false;
e31e01e8 40
5d10d135 41 // ========================================================================
88144d4a 42 // Constructors
5d10d135 43 // =======================================================================
88144d4a
ASL
44 /**
45 * @param range
46 * @param offset
47 * @param nbEvents
48 * @param maxBlockSize
49 * @param listener
50 */
51 public StateDataRequest(TmfTimeRange range, long offset, int nbEvents,
52 int maxBlockSize, IStateDataRequestListener listener,
53 StateManager manager) {
28b94d61 54
e31e01e8 55 super(LttngEvent.class, range, nbEvents, maxBlockSize);
28b94d61 56 //super(0, nbEvents, maxBlockSize);
88144d4a
ASL
57 this.manager = manager;
58 if (listener != null && !listeners.contains(listener)) {
59 listeners.add(listener);
60 }
61 }
62
63 /**
64 * @param range
65 * @param offset
66 * @param nbEvents
67 * @param maxBlockSize
68 * @param listener
69 * @param transactionID
70 * optional use by user application
71 */
72 public StateDataRequest(TmfTimeRange range, long offset, int nbEvents,
73 int maxBlockSize, IStateDataRequestListener listener,
74 String transactionID, StateManager manager) {
75
76 this(range, offset, nbEvents, maxBlockSize, listener, manager);
77 this.transactionId = transactionID;
78 }
79
5d10d135 80 // ========================================================================
88144d4a 81 // Methods
5d10d135 82 // =======================================================================
88144d4a
ASL
83
84 /**
85 * Trigger the start to process this request right after the notification to
86 * the interested listeners
87 *
88 * @param experiment
89 * @param broadcast
90 * true: All views, false: only to registered listeners
91 */
e31e01e8 92 public void startRequestInd(TmfExperiment<LttngEvent> experiment, boolean broadcast,
41dc35d0 93 boolean waitForCompletion) {
88144d4a
ASL
94 if (broadcast) {
95 // Notify all state views.
96 this.broadcast = broadcast;
97 TmfSignalManager.dispatchSignal(new RequestStartedSignal(this));
98 } else {
99 // Notify specific state views
100 for (IStateDataRequestListener listener : listeners) {
101 listener.processingStarted(new RequestStartedSignal(this));
102 }
103 }
104
105 // trigger the start to process this request
41dc35d0 106 experiment.processRequest(this, waitForCompletion);
88144d4a
ASL
107 }
108
109 /**
110 * to be called by the handleCompletion in superclass method, notifies the
111 * interested listeners. i.e. if the request start indicated broadcast, the
112 * completion will also be broadcasted otherwise only registered listeners
113 * will be notified.
114 */
115 public void notifyCompletion() {
116 if (broadcast) {
117 // Notify all state views.
118 TmfSignalManager.dispatchSignal(new RequestCompletedSignal(this));
119 } else {
120 // Notify specific state views
121 for (IStateDataRequestListener listener : listeners) {
122 listener.processingCompleted(new RequestCompletedSignal(this));
123 }
124 }
125 }
126
127 public void notifyStarting() {
128 for (IStateDataRequestListener listener : listeners) {
129 listener.processingStarted(new RequestStartedSignal(this));
130 }
131 }
132
133 public String getTransactionId() {
134 return transactionId;
135 }
136
137 public StateManager getStateManager() {
138 return this.manager;
139 }
140
141 // public IStateDataRequestListener getListener() {
142 // return listener;
5d10d135 143 // }
88144d4a
ASL
144
145 public void addListener(IStateDataRequestListener listener) {
146 if (!listeners.contains(listener)) {
147 listeners.add(listener);
148 }
149 }
150
151 public void removeListener(IStateDataRequestListener listener) {
152 if (listener != null) {
153 listeners.remove(listener);
154 }
155 }
156
157 /**
158 * @param numOfEvents
159 * the numOfEvents to set
160 */
161 public void setNumOfEvents(long numOfEvents) {
162 this.numOfEvents = numOfEvents;
163 }
164
165 /**
166 * @return the numOfEvents
167 */
168 public long getNumOfEvents() {
169 return numOfEvents;
170 }
d712a5f3
FC
171
172 /**
173 * @param clearAllData
174 * indicates the need to clear all previous data e.g. a new
175 * experiment selection
176 */
177 public void setclearDataInd(boolean clearAllData) {
178 this.clearDataInd = clearAllData;
179 }
180
181 /**
182 * Returns indication - clearing of all existing data model is required e.g
183 * from the selection of a new experiment
184 *
185 * @return
186 */
187 public boolean isclearDataInd() {
188 return clearDataInd;
189 }
e31e01e8 190}
This page took 0.038023 seconds and 5 git commands to generate.