2010-06-05 fchouinard@gmail.com Contributions for bugs 292965, 292963, 293102,...
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / request / TmfCoalescedDataRequest.java
CommitLineData
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
13package org.eclipse.linuxtools.tmf.request;
14
15import java.util.Vector;
16
17import org.eclipse.linuxtools.tmf.event.TmfData;
18
19/**
20 * <b><u>TmfCoalescedDataRequest</u></b>
21 * <p>
22 * TODO: Implement me. Please.
23 */
24public class TmfCoalescedDataRequest<T extends TmfData> extends TmfDataRequest<T> {
25
26 // ------------------------------------------------------------------------
27 // Attributes
28 // ------------------------------------------------------------------------
29
2fb2eb37 30 protected Vector<ITmfDataRequest<T>> fRequests = new Vector<ITmfDataRequest<T>>();
8c8bf09f
ASL
31
32 // ------------------------------------------------------------------------
33 // Constructor
34 // ------------------------------------------------------------------------
35
36 /**
37 * Default constructor
38 */
39 public TmfCoalescedDataRequest(Class<T> dataType) {
cb866e08
FC
40 this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.SHORT);
41 }
42
43 public TmfCoalescedDataRequest(Class<T> dataType, ExecutionType execType) {
44 this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, execType);
8c8bf09f
ASL
45 }
46
47 /**
48 * @param nbRequested
49 */
50 public TmfCoalescedDataRequest(Class<T> dataType, int index) {
cb866e08
FC
51 this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.SHORT);
52 }
53
54 public TmfCoalescedDataRequest(Class<T> dataType, int index, ExecutionType execType) {
55 this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE, execType);
8c8bf09f
ASL
56 }
57
58 /**
59 * @param index
60 * @param nbRequested
61 */
62 public TmfCoalescedDataRequest(Class<T> dataType, int index, int nbRequested) {
cb866e08
FC
63 this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.SHORT);
64 }
65
66 public TmfCoalescedDataRequest(Class<T> dataType, int index, int nbRequested, ExecutionType execType) {
67 this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE, execType);
8c8bf09f
ASL
68 }
69
70 /**
71 * @param index
72 * @param nbRequested
73 * @param blockSize
74 */
75 public TmfCoalescedDataRequest(Class<T> dataType, int index, int nbRequested, int blockSize) {
cb866e08
FC
76 super(dataType, index, nbRequested, blockSize, ExecutionType.SHORT);
77 }
78
79 public TmfCoalescedDataRequest(Class<T> dataType, int index, int nbRequested, int blockSize, ExecutionType execType) {
80 super(dataType, index, nbRequested, blockSize, execType);
8c8bf09f
ASL
81 }
82
83 // ------------------------------------------------------------------------
84 // Management
85 // ------------------------------------------------------------------------
86
2fb2eb37 87 public void addRequest(ITmfDataRequest<T> request) {
8c8bf09f
ASL
88 fRequests.add(request);
89 }
90
2fb2eb37 91 public boolean isCompatible(ITmfDataRequest<T> request) {
8c8bf09f 92
2fb2eb37 93 boolean ok = request.getIndex() == getIndex();
cb866e08
FC
94 ok &= request.getNbRequested() == getNbRequested();
95 ok &= request.getBlockize() == getBlockize();
96 ok &= request.getExecType() == getExecType();
8c8bf09f
ASL
97
98 return ok;
99 }
100
101 // ------------------------------------------------------------------------
102 // ITmfDataRequest
103 // ------------------------------------------------------------------------
104
105 @Override
106 public void handleData() {
2fb2eb37 107 for (ITmfDataRequest<T> request : fRequests) {
8c8bf09f
ASL
108 request.setData(getData());
109 request.handleData();
110 }
111 }
112
113 @Override
2fb2eb37
FC
114 public void done() {
115 for (ITmfDataRequest<T> request : fRequests) {
116 request.done();
8c8bf09f 117 }
2fb2eb37 118 super.done();
8c8bf09f
ASL
119 }
120
121 @Override
2fb2eb37
FC
122 public void fail() {
123 for (ITmfDataRequest<T> request : fRequests) {
124 request.fail();
8c8bf09f 125 }
2fb2eb37 126 super.fail();
8c8bf09f
ASL
127 }
128
129 @Override
2fb2eb37
FC
130 public void cancel() {
131 for (ITmfDataRequest<T> request : fRequests) {
132 request.cancel();
8c8bf09f 133 }
2fb2eb37 134 super.cancel();
8c8bf09f
ASL
135 }
136
2fb2eb37
FC
137 // ------------------------------------------------------------------------
138 // Object
139 // ------------------------------------------------------------------------
8c8bf09f
ASL
140
141 @Override
2fb2eb37
FC
142 // All requests have a unique id
143 public int hashCode() {
144 return super.hashCode();
8c8bf09f
ASL
145 }
146
147 @Override
2fb2eb37
FC
148 public boolean equals(Object other) {
149 if (other instanceof TmfCoalescedDataRequest<?>) {
150 TmfCoalescedDataRequest<?> request = (TmfCoalescedDataRequest<?>) other;
cb866e08
FC
151 return (request.getDataType() == getDataType()) &&
152 (request.getIndex() == getIndex()) &&
153 (request.getNbRequested() == getNbRequested() &&
154 (request.getExecType() == getExecType()));
2fb2eb37
FC
155 }
156 return false;
8c8bf09f
ASL
157 }
158
159 @Override
2fb2eb37
FC
160 public String toString() {
161 return "[TmfCoalescedDataRequest(" + getRequestId() + "," + getDataType().getSimpleName()
162 + "," + getIndex() + "," + getNbRequested() + "," + getBlockize() + ")]";
8c8bf09f
ASL
163 }
164
165}
This page took 0.033451 seconds and 5 git commands to generate.