tmf: Consolidate constructors in TmfDataRequest
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / request / TmfEventRequest.java
CommitLineData
8c8bf09f 1/*******************************************************************************
61759503 2 * Copyright (c) 2009, 2013 Ericsson
0283f7ff 3 *
8c8bf09f
ASL
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
0283f7ff 8 *
8c8bf09f
ASL
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
6c13869b 13package org.eclipse.linuxtools.tmf.core.request;
8c8bf09f 14
5500a7f0 15import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
72f1e62a 16import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
3bd46eef 17import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
8c8bf09f
ASL
18
19/**
8fd82db5 20 * An extension of TmfDataRequest for timestamped events.
0283f7ff 21 *
8fd82db5
FC
22 * @version 1.0
23 * @author Francois Chouinard
8c8bf09f 24 */
6256d8ad 25public abstract class TmfEventRequest extends TmfDataRequest implements ITmfEventRequest {
8c8bf09f
ASL
26
27 // ------------------------------------------------------------------------
28 // Attributes
29 // ------------------------------------------------------------------------
30
5419a136 31 private final TmfTimeRange fRange; // The requested events time range
8c8bf09f
ASL
32
33 // ------------------------------------------------------------------------
34 // Constructors
35 // ------------------------------------------------------------------------
36
37 /**
0d9a6d76
FC
38 * Request all the events of a given type (high priority)
39 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
0283f7ff 40 *
0d9a6d76 41 * @param dataType the requested data type
8c8bf09f 42 */
6256d8ad 43 public TmfEventRequest(Class<? extends ITmfEvent> dataType) {
a4115405 44 this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
550d787e
FC
45 }
46
0d9a6d76
FC
47 /**
48 * Request all the events of a given type (given priority)
49 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
0283f7ff 50 *
0d9a6d76
FC
51 * @param dataType the requested data type
52 * @param priority the requested execution priority
53 */
6256d8ad 54 public TmfEventRequest(Class<? extends ITmfEvent> dataType, ExecutionType priority) {
0d9a6d76 55 this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
8c8bf09f
ASL
56 }
57
58 /**
0d9a6d76
FC
59 * Request all the events of a given type for the given time range (high priority)
60 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
0283f7ff 61 *
0d9a6d76
FC
62 * @param dataType the requested data type
63 * @param range the time range of the requested events
8c8bf09f 64 */
6256d8ad 65 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range) {
a79913eb 66 this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
550d787e
FC
67 }
68
0d9a6d76
FC
69 /**
70 * Request all the events of a given type for the given time range (given priority)
71 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
0283f7ff 72 *
0d9a6d76
FC
73 * @param dataType the requested data type
74 * @param range the time range of the requested events
75 * @param priority the requested execution priority
76 */
6256d8ad 77 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, ExecutionType priority) {
0d9a6d76 78 this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
8c8bf09f
ASL
79 }
80
81 /**
0d9a6d76
FC
82 * Request 'n' events of a given type from the given time range (high priority)
83 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
0283f7ff 84 *
0d9a6d76
FC
85 * @param dataType the requested data type
86 * @param range the time range of the requested events
87 * @param nbRequested the number of events requested
8c8bf09f 88 */
6256d8ad 89 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested) {
a79913eb 90 this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
550d787e 91 }
0283f7ff 92
0d9a6d76
FC
93 /**
94 * Request 'n' events of a given type for the given time range (given priority)
95 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
0283f7ff 96 *
0d9a6d76
FC
97 * @param dataType the requested data type
98 * @param range the time range of the requested events
99 * @param nbRequested the number of events requested
100 * @param priority the requested execution priority
101 */
6256d8ad 102 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, ExecutionType priority) {
0d9a6d76 103 this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, priority);
8c8bf09f 104 }
0283f7ff 105
8c8bf09f 106 /**
0d9a6d76
FC
107 * Request 'n' events of a given type for the given time range (high priority).
108 * Events are returned in blocks of the given size.
0283f7ff 109 *
0d9a6d76
FC
110 * @param dataType the requested data type
111 * @param range the time range of the requested events
112 * @param nbRequested the number of events requested
113 * @param blockSize the number of events per block
8c8bf09f 114 */
6256d8ad 115 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, int blockSize) {
a79913eb 116 this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND);
550d787e
FC
117 }
118
7e6347b0
FC
119 /**
120 * Request 'n' events of a given type for the given time range (high priority).
121 * Events are returned in blocks of the given size.
0283f7ff 122 *
7e6347b0
FC
123 * @param dataType the requested data type
124 * @param range the time range of the requested events
125 * @param index the index of the first event to retrieve
126 * @param nbRequested the number of events requested
127 * @param blockSize the number of events per block
128 */
6256d8ad 129 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize) {
7e6347b0
FC
130 this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
131 }
132
0d9a6d76
FC
133 /**
134 * Request 'n' events of a given type for the given time range (given priority).
135 * Events are returned in blocks of the given size.
0283f7ff 136 *
0d9a6d76
FC
137 * @param dataType the requested data type
138 * @param range the time range of the requested events
139 * @param nbRequested the number of events requested
140 * @param blockSize the number of events per block
141 * @param priority the requested execution priority
142 */
6256d8ad 143 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType priority) {
0d9a6d76 144 this(dataType, range, 0, nbRequested, blockSize, priority);
a79913eb
FC
145 }
146
0d9a6d76
FC
147 /**
148 * Request 'n' events of a given type for the given time range (given priority).
149 * Events are returned in blocks of the given size.
0283f7ff 150 *
0d9a6d76
FC
151 * @param dataType the requested data type
152 * @param range the time range of the requested events
153 * @param index the index of the first event to retrieve
154 * @param nbRequested the number of events requested
155 * @param blockSize the number of events per block
156 * @param priority the requested execution priority
157 */
6256d8ad 158 public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize, ExecutionType priority) {
0d9a6d76 159 super(dataType, index, nbRequested, blockSize, priority);
5419a136 160 fRange = range;
90891c08 161
5500a7f0 162 if (TmfCoreTracer.isRequestTraced()) {
90891c08
FC
163 String type = getClass().getName();
164 type = type.substring(type.lastIndexOf('.') + 1);
165 @SuppressWarnings("nls")
0283f7ff
FC
166 String message = "CREATED "
167 + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
168 + " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
4cf201de 169 + " Range=" + getRange()
90891c08 170 + " DataType=" + getDataType().getSimpleName();
5500a7f0 171 TmfCoreTracer.traceRequest(this, message);
90891c08 172 }
8c8bf09f
ASL
173 }
174
175 // ------------------------------------------------------------------------
176 // Accessors
177 // ------------------------------------------------------------------------
178
179 /**
180 * @return the requested time range
3bd46eef 181 * @since 2.0
8c8bf09f 182 */
d4011df2
FC
183 @Override
184 public TmfTimeRange getRange() {
5419a136 185 return fRange;
8c8bf09f
ASL
186 }
187
a79913eb
FC
188 // ------------------------------------------------------------------------
189 // Setters
190 // ------------------------------------------------------------------------
191
192 /**
193 * this method is called by the event provider to set the index corresponding
194 * to the time range start time once it is known
0283f7ff 195 *
0d9a6d76 196 * @param index the start index
a79913eb
FC
197 */
198 @Override
199 public void setStartIndex(int index) {
200 setIndex(index);
201 }
202
2fb2eb37
FC
203 // ------------------------------------------------------------------------
204 // Object
205 // ------------------------------------------------------------------------
206
207 @Override
208 // All requests have a unique id
209 public int hashCode() {
210 return getRequestId();
211 }
212
213 @Override
214 public boolean equals(Object other) {
6256d8ad
AM
215 if (other instanceof TmfEventRequest) {
216 TmfEventRequest request = (TmfEventRequest) other;
5419a136 217 return super.equals(other) && request.fRange.equals(fRange);
2fb2eb37
FC
218 }
219 return false;
220 }
221
222 @Override
3b38ea61 223 @SuppressWarnings("nls")
2fb2eb37 224 public String toString() {
0283f7ff 225 return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
a79913eb 226 + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
2fb2eb37
FC
227 }
228
8c8bf09f 229}
This page took 0.063237 seconds and 5 git commands to generate.