2010-06-05 fchouinard@gmail.com Contributions for bugs 292965, 292963, 293102,...
[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;
cb866e08 20import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
5d10d135
ASL
21import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
22
23/**
24 * This class is an extension of Data Request which includes specific references
25 * i.e. a status listener to indicate the start and end of the request
26 *
27 * @author alvaro
28 *
29 */
30public class LttngSyntEventRequest extends TmfEventRequest<LttngSyntheticEvent>
31 implements ILttngSyntEventRequest {
32
33 // ========================================================================
34 // Data
35 // =======================================================================
36 private Vector<IRequestStatusListener> listeners = new Vector<IRequestStatusListener>();
37 private Long feventCount = 0L;
38 private boolean clearDataInd = false;
39 private TmfTimeRange fExperimentTimeRange = null;
40 private Object fsource = null;
41 private final ITransEventProcessor fprocessor;
42
43 // ========================================================================
44 // Constructors
45 // =======================================================================
46 /**
47 * @param range
48 * @param offset
49 * @param nbEvents
50 * @param maxBlockSize
51 * @param listener
52 */
53 public LttngSyntEventRequest(TmfTimeRange range, long offset, int nbEvents,
54 int maxBlockSize, IRequestStatusListener listener,
55 TmfTimeRange experimentTimeRange, ITransEventProcessor processor) {
56
cb866e08 57 super(LttngSyntheticEvent.class, range, nbEvents, maxBlockSize, ITmfDataRequest.ExecutionType.LONG);
5d10d135
ASL
58 //super(0, nbEvents, maxBlockSize);
59 fExperimentTimeRange = experimentTimeRange;
60 addListener(listener);
61
62 fprocessor = processor;
63 }
64
65 /**
66 * @param listener
67 */
68 public void addListener(IRequestStatusListener listener) {
69 if (listener != null && !listeners.contains(listener)) {
70 listeners.add(listener);
71 }
72 }
73
74 /**
75 * @param listener
76 */
77 public void removeListner(IRequestStatusListener listener) {
78 if (listener != null) {
79 listeners.remove(listener);
80 }
81 }
82
83 // ========================================================================
84 // Methods
85 // =======================================================================
86 /* (non-Javadoc)
87 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#startRequestInd(org.eclipse.linuxtools.tmf.experiment.TmfExperiment, boolean)
88 */
89 public void startRequestInd(TmfEventProvider<LttngSyntheticEvent> provider) {
90 // trigger the start to process this request
91 provider.sendRequest(this);
92 }
93
94 /* (non-Javadoc)
95 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyCompletion()
96 */
97 public void notifyCompletion() {
98 // Notify specific state views
99 for (IRequestStatusListener listener : listeners) {
100 listener.processingCompleted(new RequestCompletedSignal(this));
101 }
102 }
103
104 /* (non-Javadoc)
105 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyStarting()
106 */
107 public void notifyStarting() {
108 for (IRequestStatusListener listener : listeners) {
109 listener.processingStarted(new RequestStartedSignal(this));
110 }
111 }
112
113 /* (non-Javadoc)
114 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#getExperimentTimeRange()
115 */
116 public TmfTimeRange getExperimentTimeRange() {
117 return fExperimentTimeRange;
118 }
119
120 /*
121 * (non-Javadoc)
122 *
123 * @see
124 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#setSynEventCount
125 * (java.lang.Long)
126 */
127 public synchronized void setSynEventCount(Long numOfEvents) {
128 this.feventCount = numOfEvents;
129 }
130
131 /*
132 * (non-Javadoc)
133 *
134 * @see
135 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#getEventCount
136 * ()
137 */
550d787e 138 public synchronized Long getSynEventCount() {
5d10d135
ASL
139 return feventCount;
140 }
141
142 /* (non-Javadoc)
143 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#setclearDataInd(boolean)
144 */
145 public void setclearDataInd(boolean clearAllData) {
146 this.clearDataInd = clearAllData;
147 }
148
149 /* (non-Javadoc)
150 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#isclearDataInd()
151 */
152 public boolean isclearDataInd() {
153 return clearDataInd;
154 }
155
156 /* (non-Javadoc)
157 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#handleData()
158 */
159 @Override
160 public void handleData() {
161 }
162
163
164 /*
165 * (non-Javadoc)
166 *
167 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
168 */
550d787e 169 @Override
5d10d135
ASL
170 public void handleCompleted() {
171 // notify listeners
172 notifyCompletion();
173 super.handleCompleted();
174 }
175
176 /**
177 * @return the source
178 */
179 public Object getSource() {
180 return fsource;
181 }
182
183 /**
184 * @param source
185 */
186 public void setSource(Object source) {
187 this.fsource = source;
188 }
189
190 /**
191 * @return the event processor associated to this request
192 */
193 public ITransEventProcessor getProcessor() {
194 return fprocessor;
195 }
196}
This page took 0.032855 seconds and 5 git commands to generate.