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) { |
a79913eb | 39 | this(dataType, TmfTimeRange.Eternity, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
40 | } |
41 | ||
42 | public TmfEventRequest(Class<T> dataType, ExecutionType execType) { | |
a79913eb | 43 | this(dataType, TmfTimeRange.Eternity, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, execType); |
8c8bf09f ASL |
44 | } |
45 | ||
46 | /** | |
47 | * @param range | |
48 | */ | |
951d134a | 49 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range) { |
a79913eb | 50 | this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
51 | } |
52 | ||
53 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, ExecutionType execType) { | |
a79913eb | 54 | this(dataType, range, 0, 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) { |
a79913eb | 62 | this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND); |
550d787e FC |
63 | } |
64 | ||
65 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, ExecutionType execType) { | |
a79913eb | 66 | this(dataType, range, 0, 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) { |
a79913eb | 75 | this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND); |
550d787e FC |
76 | } |
77 | ||
78 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType execType) { | |
a79913eb FC |
79 | this(dataType, range, 0, nbRequested, blockSize, execType); |
80 | } | |
81 | ||
82 | public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int index, int nbRequested, int blockSize, ExecutionType execType) { | |
83 | super(dataType, index, nbRequested, blockSize, execType); | |
8c8bf09f ASL |
84 | fRange = range; |
85 | } | |
86 | ||
87 | // ------------------------------------------------------------------------ | |
88 | // Accessors | |
89 | // ------------------------------------------------------------------------ | |
90 | ||
91 | /** | |
92 | * @return the requested time range | |
93 | */ | |
d4011df2 FC |
94 | @Override |
95 | public TmfTimeRange getRange() { | |
8c8bf09f ASL |
96 | return fRange; |
97 | } | |
98 | ||
a79913eb FC |
99 | // ------------------------------------------------------------------------ |
100 | // Setters | |
101 | // ------------------------------------------------------------------------ | |
102 | ||
103 | /** | |
104 | * this method is called by the event provider to set the index corresponding | |
105 | * to the time range start time once it is known | |
106 | * @param index the start time index | |
107 | */ | |
108 | @Override | |
109 | public void setStartIndex(int index) { | |
110 | setIndex(index); | |
111 | } | |
112 | ||
2fb2eb37 FC |
113 | // ------------------------------------------------------------------------ |
114 | // Object | |
115 | // ------------------------------------------------------------------------ | |
116 | ||
117 | @Override | |
118 | // All requests have a unique id | |
119 | public int hashCode() { | |
120 | return getRequestId(); | |
121 | } | |
122 | ||
123 | @Override | |
124 | public boolean equals(Object other) { | |
125 | if (other instanceof TmfEventRequest<?>) { | |
126 | TmfEventRequest<?> request = (TmfEventRequest<?>) other; | |
127 | return super.equals(other) && request.fRange.equals(fRange); | |
128 | } | |
129 | return false; | |
130 | } | |
131 | ||
132 | @Override | |
3b38ea61 | 133 | @SuppressWarnings("nls") |
2fb2eb37 FC |
134 | public String toString() { |
135 | return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName() | |
a79913eb | 136 | + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]"; |
2fb2eb37 FC |
137 | } |
138 | ||
8c8bf09f | 139 | } |