2010-09-17 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug325662
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / request / LttngSyntEventRequest.java
CommitLineData
5d10d135
ASL
1/*******************************************************************************
2 * Copyright (c) 2009, 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 *******************************************************************************/
12package org.eclipse.linuxtools.lttng.request;
13
14import java.util.Vector;
15
16import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent;
17import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor;
18import org.eclipse.linuxtools.tmf.component.TmfEventProvider;
19import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
20import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
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 */
29public class LttngSyntEventRequest extends TmfEventRequest<LttngSyntheticEvent>
30 implements ILttngSyntEventRequest {
31
32 // ========================================================================
33 // Data
34 // =======================================================================
35 private Vector<IRequestStatusListener> listeners = new Vector<IRequestStatusListener>();
36 private Long feventCount = 0L;
37 private boolean clearDataInd = false;
38 private TmfTimeRange fExperimentTimeRange = null;
39 private Object fsource = null;
40 private final ITransEventProcessor fprocessor;
41
42 // ========================================================================
43 // Constructors
44 // =======================================================================
45 /**
46 * @param range
47 * @param offset
48 * @param nbEvents
49 * @param maxBlockSize
50 * @param listener
51 */
52 public LttngSyntEventRequest(TmfTimeRange range, long offset, int nbEvents,
53 int maxBlockSize, IRequestStatusListener listener,
54 TmfTimeRange experimentTimeRange, ITransEventProcessor processor) {
55
f6b14ce2 56 this(range, offset, nbEvents, maxBlockSize, listener, experimentTimeRange, processor, ExecutionType.FOREGROUND);
9b635e61
FC
57 }
58
59 /**
60 * @param range
61 * @param offset
62 * @param nbEvents
63 * @param maxBlockSize
64 * @param listener
65 */
66 public LttngSyntEventRequest(TmfTimeRange range, long offset, int nbEvents,
67 int maxBlockSize, IRequestStatusListener listener,
68 TmfTimeRange experimentTimeRange, ITransEventProcessor processor, ExecutionType execType) {
69
70 super(LttngSyntheticEvent.class, range, nbEvents, maxBlockSize, execType);
5d10d135
ASL
71 fExperimentTimeRange = experimentTimeRange;
72 addListener(listener);
73
74 fprocessor = processor;
75 }
76
77 /**
78 * @param listener
79 */
80 public void addListener(IRequestStatusListener listener) {
81 if (listener != null && !listeners.contains(listener)) {
82 listeners.add(listener);
83 }
84 }
85
86 /**
87 * @param listener
88 */
89 public void removeListner(IRequestStatusListener listener) {
90 if (listener != null) {
91 listeners.remove(listener);
92 }
93 }
94
95 // ========================================================================
96 // Methods
97 // =======================================================================
98 /* (non-Javadoc)
99 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#startRequestInd(org.eclipse.linuxtools.tmf.experiment.TmfExperiment, boolean)
100 */
101 public void startRequestInd(TmfEventProvider<LttngSyntheticEvent> provider) {
102 // trigger the start to process this request
103 provider.sendRequest(this);
104 }
105
106 /* (non-Javadoc)
107 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyCompletion()
108 */
109 public void notifyCompletion() {
110 // Notify specific state views
111 for (IRequestStatusListener listener : listeners) {
112 listener.processingCompleted(new RequestCompletedSignal(this));
113 }
114 }
115
116 /* (non-Javadoc)
117 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyStarting()
118 */
119 public void notifyStarting() {
120 for (IRequestStatusListener listener : listeners) {
121 listener.processingStarted(new RequestStartedSignal(this));
122 }
123 }
124
125 /* (non-Javadoc)
126 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#getExperimentTimeRange()
127 */
128 public TmfTimeRange getExperimentTimeRange() {
129 return fExperimentTimeRange;
130 }
131
132 /*
133 * (non-Javadoc)
134 *
135 * @see
136 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#setSynEventCount
137 * (java.lang.Long)
138 */
139 public synchronized void setSynEventCount(Long numOfEvents) {
140 this.feventCount = numOfEvents;
141 }
142
143 /*
144 * (non-Javadoc)
145 *
146 * @see
147 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#getEventCount
148 * ()
149 */
550d787e 150 public synchronized Long getSynEventCount() {
5d10d135
ASL
151 return feventCount;
152 }
153
154 /* (non-Javadoc)
155 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#setclearDataInd(boolean)
156 */
157 public void setclearDataInd(boolean clearAllData) {
158 this.clearDataInd = clearAllData;
159 }
160
161 /* (non-Javadoc)
162 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#isclearDataInd()
163 */
164 public boolean isclearDataInd() {
165 return clearDataInd;
166 }
167
168 /* (non-Javadoc)
169 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#handleData()
170 */
171 @Override
f9673903
FC
172 public void handleData(LttngSyntheticEvent event) {
173 super.handleData(event);
5d10d135
ASL
174 }
175
176
177 /*
178 * (non-Javadoc)
179 *
180 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
181 */
550d787e 182 @Override
5d10d135
ASL
183 public void handleCompleted() {
184 // notify listeners
185 notifyCompletion();
186 super.handleCompleted();
187 }
188
189 /**
190 * @return the source
191 */
192 public Object getSource() {
193 return fsource;
194 }
195
196 /**
197 * @param source
198 */
199 public void setSource(Object source) {
200 this.fsource = source;
201 }
202
203 /**
204 * @return the event processor associated to this request
205 */
206 public ITransEventProcessor getProcessor() {
207 return fprocessor;
208 }
209}
This page took 0.035051 seconds and 5 git commands to generate.