David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 1 | // 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 Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame^] | 12 | namespace facebook { namespace thrift { namespace protocol { |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 13 | |
| 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 | */ |
| 20 | class 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 Reiss | 96d2388 | 2007-07-26 21:10:32 +0000 | [diff] [blame] | 38 | TMessageType& messageType, |
| 39 | int32_t& seqid) { |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 40 | 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 Reiss | 96d2388 | 2007-07-26 21:10:32 +0000 | [diff] [blame] | 60 | TType& fieldType, |
| 61 | int16_t& fieldId) { |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 62 | throw TProtocolException(TProtocolException::NOT_IMPLEMENTED, |
| 63 | subclass_ + " does not support reading (yet)."); |
| 64 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame^] | 65 | |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 66 | uint32_t readFieldEnd() { |
| 67 | throw TProtocolException(TProtocolException::NOT_IMPLEMENTED, |
| 68 | subclass_ + " does not support reading (yet)."); |
| 69 | } |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame^] | 70 | |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 71 | uint32_t readMapBegin(TType& keyType, |
David Reiss | 96d2388 | 2007-07-26 21:10:32 +0000 | [diff] [blame] | 72 | TType& valType, |
| 73 | uint32_t& size) { |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 74 | 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 Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame^] | 88 | |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 89 | 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 Reiss | 96d2388 | 2007-07-26 21:10:32 +0000 | [diff] [blame] | 95 | uint32_t& size) { |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 96 | 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_ |