Commit | Line | Data |
---|---|---|
8c8bf09f 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 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.request; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.event.TmfEvent; | |
16 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; | |
17 | ||
18 | /** | |
19 | * <b><u>TmfEventRequest</u></b> | |
20 | * <p> | |
21 | * Implement me. Please. | |
22 | */ | |
951d134a | 23 | public abstract class TmfEventRequest<T extends TmfEvent> extends TmfDataRequest<T> implements ITmfEventRequest<T> { |
8c8bf09f ASL |
24 | |
25 | // ------------------------------------------------------------------------ | |
26 | // Attributes | |
27 | // ------------------------------------------------------------------------ | |
28 | ||
29 | private final TmfTimeRange fRange; // The requested events time range | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Constructors | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
35 | /** | |
36 | * @param range | |
37 | */ | |
951d134a | 38 | public TmfEventRequest(Class<T> dataType) { |
f6b14ce2 | 39 | this(dataType, TmfTimeRange.Eternity, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
40 | } |
41 | ||
42 | public TmfEventRequest(Class<T> dataType, ExecutionType execType) { | |
43 | this(dataType, TmfTimeRange.Eternity, ALL_DATA, DEFAULT_BLOCK_SIZE, execType); | |
8c8bf09f ASL |
44 | } |
45 | ||
46 | /** | |
47 | * @param range | |
48 | */ | |
951d134a | 49 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range) { |
f6b14ce2 | 50 | this(dataType, range, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
51 | } |
52 | ||
53 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, ExecutionType execType) { | |
54 | this(dataType, range, ALL_DATA, DEFAULT_BLOCK_SIZE, execType); | |
8c8bf09f ASL |
55 | } |
56 | ||
57 | /** | |
58 | * @param range | |
59 | * @param nbRequested | |
60 | */ | |
951d134a | 61 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested) { |
f6b14ce2 | 62 | this(dataType, range, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
63 | } |
64 | ||
65 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, ExecutionType execType) { | |
66 | this(dataType, range, nbRequested, DEFAULT_BLOCK_SIZE, execType); | |
8c8bf09f ASL |
67 | } |
68 | ||
69 | /** | |
70 | * @param range | |
71 | * @param nbRequested | |
72 | * @param blockSize Size of the largest blocks expected | |
73 | */ | |
951d134a | 74 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize) { |
f6b14ce2 | 75 | super(dataType, 0, nbRequested, blockSize, ExecutionType.FOREGROUND); |
550d787e FC |
76 | fRange = range; |
77 | } | |
78 | ||
79 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType execType) { | |
80 | super(dataType, 0, nbRequested, blockSize, execType); | |
8c8bf09f ASL |
81 | fRange = range; |
82 | } | |
83 | ||
84 | // ------------------------------------------------------------------------ | |
85 | // Accessors | |
86 | // ------------------------------------------------------------------------ | |
87 | ||
88 | /** | |
89 | * @return the requested time range | |
90 | */ | |
91 | public TmfTimeRange getRange() { | |
92 | return fRange; | |
93 | } | |
94 | ||
2fb2eb37 FC |
95 | // ------------------------------------------------------------------------ |
96 | // Object | |
97 | // ------------------------------------------------------------------------ | |
98 | ||
99 | @Override | |
100 | // All requests have a unique id | |
101 | public int hashCode() { | |
102 | return getRequestId(); | |
103 | } | |
104 | ||
105 | @Override | |
106 | public boolean equals(Object other) { | |
107 | if (other instanceof TmfEventRequest<?>) { | |
108 | TmfEventRequest<?> request = (TmfEventRequest<?>) other; | |
109 | return super.equals(other) && request.fRange.equals(fRange); | |
110 | } | |
111 | return false; | |
112 | } | |
113 | ||
114 | @Override | |
115 | public String toString() { | |
116 | return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName() | |
f9673903 | 117 | + "," + getRange() + "," + getNbRequested() + ")]"; |
2fb2eb37 FC |
118 | } |
119 | ||
8c8bf09f | 120 | } |