| 30 |
ashish |
1 |
/*
|
|
|
2 |
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
3 |
* or more contributor license agreements. See the NOTICE file
|
|
|
4 |
* distributed with this work for additional information
|
|
|
5 |
* regarding copyright ownership. The ASF licenses this file
|
|
|
6 |
* to you under the Apache License, Version 2.0 (the
|
|
|
7 |
* "License"); you may not use this file except in compliance
|
|
|
8 |
* with the License. You may obtain a copy of the License at
|
|
|
9 |
*
|
|
|
10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
11 |
*
|
|
|
12 |
* Unless required by applicable law or agreed to in writing,
|
|
|
13 |
* software distributed under the License is distributed on an
|
|
|
14 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
15 |
* KIND, either express or implied. See the License for the
|
|
|
16 |
* specific language governing permissions and limitations
|
|
|
17 |
* under the License.
|
|
|
18 |
*/
|
|
|
19 |
|
|
|
20 |
#ifndef _THRIFT_PROTOCOL_TONEWAYPROTOCOL_H_
|
|
|
21 |
#define _THRIFT_PROTOCOL_TONEWAYPROTOCOL_H_ 1
|
|
|
22 |
|
|
|
23 |
#include "TProtocol.h"
|
|
|
24 |
|
|
|
25 |
namespace apache { namespace thrift { namespace protocol {
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Abstract class for implementing a protocol that can only be written,
|
|
|
29 |
* not read.
|
|
|
30 |
*
|
|
|
31 |
*/
|
|
|
32 |
class TWriteOnlyProtocol : public TProtocol {
|
|
|
33 |
public:
|
|
|
34 |
/**
|
|
|
35 |
* @param subclass_name The name of the concrete subclass.
|
|
|
36 |
*/
|
|
|
37 |
TWriteOnlyProtocol(boost::shared_ptr<TTransport> trans,
|
|
|
38 |
const std::string& subclass_name)
|
|
|
39 |
: TProtocol(trans)
|
|
|
40 |
, subclass_(subclass_name)
|
|
|
41 |
{}
|
|
|
42 |
|
|
|
43 |
// All writing functions remain abstract.
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* Reading functions all throw an exception.
|
|
|
47 |
*/
|
|
|
48 |
|
|
|
49 |
uint32_t readMessageBegin(std::string& name,
|
|
|
50 |
TMessageType& messageType,
|
|
|
51 |
int32_t& seqid) {
|
|
|
52 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
53 |
subclass_ + " does not support reading (yet).");
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
uint32_t readMessageEnd() {
|
|
|
57 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
58 |
subclass_ + " does not support reading (yet).");
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
uint32_t readStructBegin(std::string& name) {
|
|
|
62 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
63 |
subclass_ + " does not support reading (yet).");
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
uint32_t readStructEnd() {
|
|
|
67 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
68 |
subclass_ + " does not support reading (yet).");
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
uint32_t readFieldBegin(std::string& name,
|
|
|
72 |
TType& fieldType,
|
|
|
73 |
int16_t& fieldId) {
|
|
|
74 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
75 |
subclass_ + " does not support reading (yet).");
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
uint32_t readFieldEnd() {
|
|
|
79 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
80 |
subclass_ + " does not support reading (yet).");
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
uint32_t readMapBegin(TType& keyType,
|
|
|
84 |
TType& valType,
|
|
|
85 |
uint32_t& size) {
|
|
|
86 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
87 |
subclass_ + " does not support reading (yet).");
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
uint32_t readMapEnd() {
|
|
|
91 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
92 |
subclass_ + " does not support reading (yet).");
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
uint32_t readListBegin(TType& elemType,
|
|
|
96 |
uint32_t& size) {
|
|
|
97 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
98 |
subclass_ + " does not support reading (yet).");
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
uint32_t readListEnd() {
|
|
|
102 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
103 |
subclass_ + " does not support reading (yet).");
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
uint32_t readSetBegin(TType& elemType,
|
|
|
107 |
uint32_t& size) {
|
|
|
108 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
109 |
subclass_ + " does not support reading (yet).");
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
uint32_t readSetEnd() {
|
|
|
113 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
114 |
subclass_ + " does not support reading (yet).");
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
uint32_t readBool(bool& value) {
|
|
|
118 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
119 |
subclass_ + " does not support reading (yet).");
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
uint32_t readByte(int8_t& byte) {
|
|
|
123 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
124 |
subclass_ + " does not support reading (yet).");
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
uint32_t readI16(int16_t& i16) {
|
|
|
128 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
129 |
subclass_ + " does not support reading (yet).");
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
uint32_t readI32(int32_t& i32) {
|
|
|
133 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
134 |
subclass_ + " does not support reading (yet).");
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
uint32_t readI64(int64_t& i64) {
|
|
|
138 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
139 |
subclass_ + " does not support reading (yet).");
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
uint32_t readDouble(double& dub) {
|
|
|
143 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
144 |
subclass_ + " does not support reading (yet).");
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
uint32_t readString(std::string& str) {
|
|
|
148 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
149 |
subclass_ + " does not support reading (yet).");
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
uint32_t readBinary(std::string& str) {
|
|
|
153 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
154 |
subclass_ + " does not support reading (yet).");
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
private:
|
|
|
158 |
std::string subclass_;
|
|
|
159 |
};
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
/**
|
|
|
163 |
* Abstract class for implementing a protocol that can only be read,
|
|
|
164 |
* not written.
|
|
|
165 |
*
|
|
|
166 |
*/
|
|
|
167 |
class TReadOnlyProtocol : public TProtocol {
|
|
|
168 |
public:
|
|
|
169 |
/**
|
|
|
170 |
* @param subclass_name The name of the concrete subclass.
|
|
|
171 |
*/
|
|
|
172 |
TReadOnlyProtocol(boost::shared_ptr<TTransport> trans,
|
|
|
173 |
const std::string& subclass_name)
|
|
|
174 |
: TProtocol(trans)
|
|
|
175 |
, subclass_(subclass_name)
|
|
|
176 |
{}
|
|
|
177 |
|
|
|
178 |
// All reading functions remain abstract.
|
|
|
179 |
|
|
|
180 |
/**
|
|
|
181 |
* Writing functions all throw an exception.
|
|
|
182 |
*/
|
|
|
183 |
|
|
|
184 |
uint32_t writeMessageBegin(const std::string& name,
|
|
|
185 |
const TMessageType messageType,
|
|
|
186 |
const int32_t seqid) {
|
|
|
187 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
188 |
subclass_ + " does not support writing (yet).");
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
uint32_t writeMessageEnd() {
|
|
|
192 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
193 |
subclass_ + " does not support writing (yet).");
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
uint32_t writeStructBegin(const char* name) {
|
|
|
198 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
199 |
subclass_ + " does not support writing (yet).");
|
|
|
200 |
}
|
|
|
201 |
|
|
|
202 |
uint32_t writeStructEnd() {
|
|
|
203 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
204 |
subclass_ + " does not support writing (yet).");
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
uint32_t writeFieldBegin(const char* name,
|
|
|
208 |
const TType fieldType,
|
|
|
209 |
const int16_t fieldId) {
|
|
|
210 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
211 |
subclass_ + " does not support writing (yet).");
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
uint32_t writeFieldEnd() {
|
|
|
215 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
216 |
subclass_ + " does not support writing (yet).");
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
uint32_t writeFieldStop() {
|
|
|
220 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
221 |
subclass_ + " does not support writing (yet).");
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
uint32_t writeMapBegin(const TType keyType,
|
|
|
225 |
const TType valType,
|
|
|
226 |
const uint32_t size) {
|
|
|
227 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
228 |
subclass_ + " does not support writing (yet).");
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
uint32_t writeMapEnd() {
|
|
|
232 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
233 |
subclass_ + " does not support writing (yet).");
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
uint32_t writeListBegin(const TType elemType,
|
|
|
237 |
const uint32_t size) {
|
|
|
238 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
239 |
subclass_ + " does not support writing (yet).");
|
|
|
240 |
}
|
|
|
241 |
|
|
|
242 |
uint32_t writeListEnd() {
|
|
|
243 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
244 |
subclass_ + " does not support writing (yet).");
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
uint32_t writeSetBegin(const TType elemType,
|
|
|
248 |
const uint32_t size) {
|
|
|
249 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
250 |
subclass_ + " does not support writing (yet).");
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
uint32_t writeSetEnd() {
|
|
|
254 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
255 |
subclass_ + " does not support writing (yet).");
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
uint32_t writeBool(const bool value) {
|
|
|
259 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
260 |
subclass_ + " does not support writing (yet).");
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
uint32_t writeByte(const int8_t byte) {
|
|
|
264 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
265 |
subclass_ + " does not support writing (yet).");
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
uint32_t writeI16(const int16_t i16) {
|
|
|
269 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
270 |
subclass_ + " does not support writing (yet).");
|
|
|
271 |
}
|
|
|
272 |
|
|
|
273 |
uint32_t writeI32(const int32_t i32) {
|
|
|
274 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
275 |
subclass_ + " does not support writing (yet).");
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
uint32_t writeI64(const int64_t i64) {
|
|
|
279 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
280 |
subclass_ + " does not support writing (yet).");
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
uint32_t writeDouble(const double dub) {
|
|
|
284 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
285 |
subclass_ + " does not support writing (yet).");
|
|
|
286 |
}
|
|
|
287 |
|
|
|
288 |
uint32_t writeString(const std::string& str) {
|
|
|
289 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
290 |
subclass_ + " does not support writing (yet).");
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
uint32_t writeBinary(const std::string& str) {
|
|
|
294 |
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
|
|
|
295 |
subclass_ + " does not support writing (yet).");
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
private:
|
|
|
299 |
std::string subclass_;
|
|
|
300 |
};
|
|
|
301 |
|
|
|
302 |
}}} // apache::thrift::protocol
|
|
|
303 |
|
|
|
304 |
#endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_
|