blob: 245f830567567288820c4e4484777ea6ce775699 [file] [log] [blame]
David Reiss00dcccf2007-07-21 01:18:10 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
7#ifndef _THRIFT_PROTOCOL_TONEWAYPROTOCOL_H_
8#define _THRIFT_PROTOCOL_TONEWAYPROTOCOL_H_ 1
9
10#include "TProtocol.h"
11
David Reiss0c90f6f2008-02-06 22:18:40 +000012namespace facebook { namespace thrift { namespace protocol {
David Reiss00dcccf2007-07-21 01:18:10 +000013
14/**
15 * Abstract class for implementing a protocol that can only be written,
16 * not read.
17 *
18 * @author David Reiss <dreiss@facebook.com>
19 */
20class TWriteOnlyProtocol : public TProtocol {
21 public:
22 /**
23 * @param subclass_name The name of the concrete subclass.
24 */
25 TWriteOnlyProtocol(boost::shared_ptr<TTransport> trans,
26 const std::string& subclass_name)
27 : TProtocol(trans)
28 , subclass_(subclass_name)
29 {}
30
31 // All writing functions remain abstract.
32
33 /**
34 * Reading functions all throw an exception.
35 */
36
37 uint32_t readMessageBegin(std::string& name,
David Reiss96d23882007-07-26 21:10:32 +000038 TMessageType& messageType,
39 int32_t& seqid) {
David Reiss00dcccf2007-07-21 01:18:10 +000040 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
41 subclass_ + " does not support reading (yet).");
42 }
43
44 uint32_t readMessageEnd() {
45 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
46 subclass_ + " does not support reading (yet).");
47 }
48
49 uint32_t readStructBegin(std::string& name) {
50 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
51 subclass_ + " does not support reading (yet).");
52 }
53
54 uint32_t readStructEnd() {
55 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
56 subclass_ + " does not support reading (yet).");
57 }
58
59 uint32_t readFieldBegin(std::string& name,
David Reiss96d23882007-07-26 21:10:32 +000060 TType& fieldType,
61 int16_t& fieldId) {
David Reiss00dcccf2007-07-21 01:18:10 +000062 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
63 subclass_ + " does not support reading (yet).");
64 }
David Reiss0c90f6f2008-02-06 22:18:40 +000065
David Reiss00dcccf2007-07-21 01:18:10 +000066 uint32_t readFieldEnd() {
67 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
68 subclass_ + " does not support reading (yet).");
69 }
David Reiss0c90f6f2008-02-06 22:18:40 +000070
David Reiss00dcccf2007-07-21 01:18:10 +000071 uint32_t readMapBegin(TType& keyType,
David Reiss96d23882007-07-26 21:10:32 +000072 TType& valType,
73 uint32_t& size) {
David Reiss00dcccf2007-07-21 01:18:10 +000074 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
75 subclass_ + " does not support reading (yet).");
76 }
77
78 uint32_t readMapEnd() {
79 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
80 subclass_ + " does not support reading (yet).");
81 }
82
83 uint32_t readListBegin(TType& elemType,
84 uint32_t& size) {
85 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
86 subclass_ + " does not support reading (yet).");
87 }
David Reiss0c90f6f2008-02-06 22:18:40 +000088
David Reiss00dcccf2007-07-21 01:18:10 +000089 uint32_t readListEnd() {
90 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
91 subclass_ + " does not support reading (yet).");
92 }
93
94 uint32_t readSetBegin(TType& elemType,
David Reiss96d23882007-07-26 21:10:32 +000095 uint32_t& size) {
David Reiss00dcccf2007-07-21 01:18:10 +000096 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
97 subclass_ + " does not support reading (yet).");
98 }
99
100 uint32_t readSetEnd() {
101 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
102 subclass_ + " does not support reading (yet).");
103 }
104
105 uint32_t readBool(bool& value) {
106 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
107 subclass_ + " does not support reading (yet).");
108 }
109
110 uint32_t readByte(int8_t& byte) {
111 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
112 subclass_ + " does not support reading (yet).");
113 }
114
115 uint32_t readI16(int16_t& i16) {
116 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
117 subclass_ + " does not support reading (yet).");
118 }
119
120 uint32_t readI32(int32_t& i32) {
121 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
122 subclass_ + " does not support reading (yet).");
123 }
124
125 uint32_t readI64(int64_t& i64) {
126 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
127 subclass_ + " does not support reading (yet).");
128 }
129
130 uint32_t readDouble(double& dub) {
131 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
132 subclass_ + " does not support reading (yet).");
133 }
134
135 uint32_t readString(std::string& str) {
136 throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
137 subclass_ + " does not support reading (yet).");
138 }
139
140
141 private:
142 std::string subclass_;
143};
144
145}}} // facebook::thrift::protocol
146
147#endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_