*
* TODO: Implement request failures (codes, etc...)
*/
-public class TmfDataRequest<T extends TmfData> {
+public abstract class TmfDataRequest<T extends TmfData> implements ITmfDataRequest<T> {
// ------------------------------------------------------------------------
// Constants
// Attributes
// ------------------------------------------------------------------------
- private final Class<? extends TmfData> fDataType;
+ private final Class<T> fDataType;
private final int fRequestId; // A unique request ID
private final int fIndex; // The index (rank) of the requested event
private final int fNbRequested; // The number of requested events (ALL_DATA for all)
/**
* Default constructor
*/
- public TmfDataRequest(Class<? extends TmfData> dataType) {
+ public TmfDataRequest(Class<T> dataType) {
this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE);
}
/**
* @param nbRequested
*/
- public TmfDataRequest(Class<? extends TmfData> dataType, int index) {
+ public TmfDataRequest(Class<T> dataType, int index) {
this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE);
}
* @param index
* @param nbRequested
*/
- public TmfDataRequest(Class<? extends TmfData> dataType, int index, int nbRequested) {
+ public TmfDataRequest(Class<T> dataType, int index, int nbRequested) {
this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE);
}
* @param nbRequested
* @param blockSize
*/
- public TmfDataRequest(Class<? extends TmfData> dataType, int index, int nbRequested, int blockSize) {
+ public TmfDataRequest(Class<T> dataType, int index, int nbRequested, int blockSize) {
fRequestId = fRequestNumber++;
fDataType = dataType;
fIndex = index;
fBlockSize = blockSize;
fNbRead = 0;
}
-
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof TmfDataRequest<?>) {
+ TmfDataRequest<?> request = (TmfDataRequest<?>) other;
+ return (request.fDataType == fDataType) &&
+ (request.fIndex == fIndex) &&
+ (request.fNbRequested == fNbRequested);
+ }
+ return false;
+ }
+
+// @Override
+// public int hashCode() {
+// int hash = 0;
+// return hash;
+// }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
}
/**
- * @return the index
+ * @return the index of the first event requested
*/
- public long getIndex() {
+ public int getIndex() {
return fIndex;
}
/**
* @return the requested data type
*/
- public Class<?> getDataType() {
+ public Class<T> getDataType() {
return fDataType;
}
*
* @param events - an array of events
*/
- public void handleData() {
- }
+ public abstract void handleData();
/**
* Handle the completion of the request. It is called when there is no more