ee8bd416dcd27e78ecbcb7b342dd374c33c78fb0
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / request / LttngSyntEventRequest.java
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 *******************************************************************************/
12 package org.eclipse.linuxtools.lttng.request;
13
14 import java.util.Vector;
15
16 import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent;
17 import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor;
18 import org.eclipse.linuxtools.tmf.component.TmfEventProvider;
19 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
20 import 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 */
29 public 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
56 super(LttngSyntheticEvent.class, range, nbEvents, maxBlockSize);
57 //super(0, nbEvents, maxBlockSize);
58 fExperimentTimeRange = experimentTimeRange;
59 addListener(listener);
60
61 fprocessor = processor;
62 }
63
64 /**
65 * @param listener
66 */
67 public void addListener(IRequestStatusListener listener) {
68 if (listener != null && !listeners.contains(listener)) {
69 listeners.add(listener);
70 }
71 }
72
73 /**
74 * @param listener
75 */
76 public void removeListner(IRequestStatusListener listener) {
77 if (listener != null) {
78 listeners.remove(listener);
79 }
80 }
81
82 // ========================================================================
83 // Methods
84 // =======================================================================
85 /* (non-Javadoc)
86 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#startRequestInd(org.eclipse.linuxtools.tmf.experiment.TmfExperiment, boolean)
87 */
88 public void startRequestInd(TmfEventProvider<LttngSyntheticEvent> provider) {
89 // trigger the start to process this request
90 provider.sendRequest(this);
91 }
92
93 /* (non-Javadoc)
94 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyCompletion()
95 */
96 public void notifyCompletion() {
97 // Notify specific state views
98 for (IRequestStatusListener listener : listeners) {
99 listener.processingCompleted(new RequestCompletedSignal(this));
100 }
101 }
102
103 /* (non-Javadoc)
104 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyStarting()
105 */
106 public void notifyStarting() {
107 for (IRequestStatusListener listener : listeners) {
108 listener.processingStarted(new RequestStartedSignal(this));
109 }
110 }
111
112 /* (non-Javadoc)
113 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#getExperimentTimeRange()
114 */
115 public TmfTimeRange getExperimentTimeRange() {
116 return fExperimentTimeRange;
117 }
118
119 /*
120 * (non-Javadoc)
121 *
122 * @see
123 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#setSynEventCount
124 * (java.lang.Long)
125 */
126 public synchronized void setSynEventCount(Long numOfEvents) {
127 this.feventCount = numOfEvents;
128 }
129
130 /*
131 * (non-Javadoc)
132 *
133 * @see
134 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#getEventCount
135 * ()
136 */
137 public Long getSynEventCount() {
138 return feventCount;
139 }
140
141 /* (non-Javadoc)
142 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#setclearDataInd(boolean)
143 */
144 public void setclearDataInd(boolean clearAllData) {
145 this.clearDataInd = clearAllData;
146 }
147
148 /* (non-Javadoc)
149 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#isclearDataInd()
150 */
151 public boolean isclearDataInd() {
152 return clearDataInd;
153 }
154
155 /* (non-Javadoc)
156 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#handleData()
157 */
158 @Override
159 public void handleData() {
160 }
161
162
163 /*
164 * (non-Javadoc)
165 *
166 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
167 */
168 public void handleCompleted() {
169 // notify listeners
170 notifyCompletion();
171 super.handleCompleted();
172 }
173
174 /**
175 * @return the source
176 */
177 public Object getSource() {
178 return fsource;
179 }
180
181 /**
182 * @param source
183 */
184 public void setSource(Object source) {
185 this.fsource = source;
186 }
187
188 /**
189 * @return the event processor associated to this request
190 */
191 public ITransEventProcessor getProcessor() {
192 return fprocessor;
193 }
194 }
This page took 0.03362 seconds and 4 git commands to generate.