]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
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 | * Contains some contributions under the Thrift Software License. | |
20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for | |
21 | * details. | |
22 | */ | |
23 | ||
24 | using System; | |
25 | using System.Text; | |
26 | using Thrift.Transport; | |
27 | using System.Collections.Generic; | |
28 | ||
29 | namespace Thrift.Protocol | |
30 | { | |
31 | /// <summary> | |
32 | /// <see cref="TProtocolDecorator"/> forwards all requests to an enclosed <see cref="TProtocol"/> instance, | |
33 | /// providing a way to author concise concrete decorator subclasses. While it has | |
34 | /// no abstract methods, it is marked abstract as a reminder that by itself, | |
35 | /// it does not modify the behaviour of the enclosed <see cref="TProtocol"/>. | |
36 | /// <para/> | |
37 | /// See p.175 of Design Patterns (by Gamma et al.) | |
38 | /// </summary> | |
39 | /// <seealso cref="TMultiplexedProtocol"/> | |
40 | public abstract class TProtocolDecorator : TProtocol | |
41 | { | |
42 | private TProtocol WrappedProtocol; | |
43 | ||
44 | /// <summary> | |
45 | /// Encloses the specified protocol. | |
46 | /// </summary> | |
47 | /// <param name="protocol">All operations will be forward to this protocol. Must be non-null.</param> | |
48 | public TProtocolDecorator(TProtocol protocol) | |
49 | : base(protocol.Transport) | |
50 | { | |
51 | ||
52 | WrappedProtocol = protocol; | |
53 | } | |
54 | ||
55 | public override void WriteMessageBegin(TMessage tMessage) | |
56 | { | |
57 | WrappedProtocol.WriteMessageBegin(tMessage); | |
58 | } | |
59 | ||
60 | public override void WriteMessageEnd() | |
61 | { | |
62 | WrappedProtocol.WriteMessageEnd(); | |
63 | } | |
64 | ||
65 | public override void WriteStructBegin(TStruct tStruct) | |
66 | { | |
67 | WrappedProtocol.WriteStructBegin(tStruct); | |
68 | } | |
69 | ||
70 | public override void WriteStructEnd() | |
71 | { | |
72 | WrappedProtocol.WriteStructEnd(); | |
73 | } | |
74 | ||
75 | public override void WriteFieldBegin(TField tField) | |
76 | { | |
77 | WrappedProtocol.WriteFieldBegin(tField); | |
78 | } | |
79 | ||
80 | public override void WriteFieldEnd() | |
81 | { | |
82 | WrappedProtocol.WriteFieldEnd(); | |
83 | } | |
84 | ||
85 | public override void WriteFieldStop() | |
86 | { | |
87 | WrappedProtocol.WriteFieldStop(); | |
88 | } | |
89 | ||
90 | public override void WriteMapBegin(TMap tMap) | |
91 | { | |
92 | WrappedProtocol.WriteMapBegin(tMap); | |
93 | } | |
94 | ||
95 | public override void WriteMapEnd() | |
96 | { | |
97 | WrappedProtocol.WriteMapEnd(); | |
98 | } | |
99 | ||
100 | public override void WriteListBegin(TList tList) | |
101 | { | |
102 | WrappedProtocol.WriteListBegin(tList); | |
103 | } | |
104 | ||
105 | public override void WriteListEnd() | |
106 | { | |
107 | WrappedProtocol.WriteListEnd(); | |
108 | } | |
109 | ||
110 | public override void WriteSetBegin(TSet tSet) | |
111 | { | |
112 | WrappedProtocol.WriteSetBegin(tSet); | |
113 | } | |
114 | ||
115 | public override void WriteSetEnd() | |
116 | { | |
117 | WrappedProtocol.WriteSetEnd(); | |
118 | } | |
119 | ||
120 | public override void WriteBool(bool b) | |
121 | { | |
122 | WrappedProtocol.WriteBool(b); | |
123 | } | |
124 | ||
125 | public override void WriteByte(sbyte b) | |
126 | { | |
127 | WrappedProtocol.WriteByte(b); | |
128 | } | |
129 | ||
130 | public override void WriteI16(short i) | |
131 | { | |
132 | WrappedProtocol.WriteI16(i); | |
133 | } | |
134 | ||
135 | public override void WriteI32(int i) | |
136 | { | |
137 | WrappedProtocol.WriteI32(i); | |
138 | } | |
139 | ||
140 | public override void WriteI64(long l) | |
141 | { | |
142 | WrappedProtocol.WriteI64(l); | |
143 | } | |
144 | ||
145 | public override void WriteDouble(double v) | |
146 | { | |
147 | WrappedProtocol.WriteDouble(v); | |
148 | } | |
149 | ||
150 | public override void WriteString(string s) | |
151 | { | |
152 | WrappedProtocol.WriteString(s); | |
153 | } | |
154 | ||
155 | public override void WriteBinary(byte[] bytes) | |
156 | { | |
157 | WrappedProtocol.WriteBinary(bytes); | |
158 | } | |
159 | ||
160 | public override TMessage ReadMessageBegin() | |
161 | { | |
162 | return WrappedProtocol.ReadMessageBegin(); | |
163 | } | |
164 | ||
165 | public override void ReadMessageEnd() | |
166 | { | |
167 | WrappedProtocol.ReadMessageEnd(); | |
168 | } | |
169 | ||
170 | public override TStruct ReadStructBegin() | |
171 | { | |
172 | return WrappedProtocol.ReadStructBegin(); | |
173 | } | |
174 | ||
175 | public override void ReadStructEnd() | |
176 | { | |
177 | WrappedProtocol.ReadStructEnd(); | |
178 | } | |
179 | ||
180 | public override TField ReadFieldBegin() | |
181 | { | |
182 | return WrappedProtocol.ReadFieldBegin(); | |
183 | } | |
184 | ||
185 | public override void ReadFieldEnd() | |
186 | { | |
187 | WrappedProtocol.ReadFieldEnd(); | |
188 | } | |
189 | ||
190 | public override TMap ReadMapBegin() | |
191 | { | |
192 | return WrappedProtocol.ReadMapBegin(); | |
193 | } | |
194 | ||
195 | public override void ReadMapEnd() | |
196 | { | |
197 | WrappedProtocol.ReadMapEnd(); | |
198 | } | |
199 | ||
200 | public override TList ReadListBegin() | |
201 | { | |
202 | return WrappedProtocol.ReadListBegin(); | |
203 | } | |
204 | ||
205 | public override void ReadListEnd() | |
206 | { | |
207 | WrappedProtocol.ReadListEnd(); | |
208 | } | |
209 | ||
210 | public override TSet ReadSetBegin() | |
211 | { | |
212 | return WrappedProtocol.ReadSetBegin(); | |
213 | } | |
214 | ||
215 | public override void ReadSetEnd() | |
216 | { | |
217 | WrappedProtocol.ReadSetEnd(); | |
218 | } | |
219 | ||
220 | public override bool ReadBool() | |
221 | { | |
222 | return WrappedProtocol.ReadBool(); | |
223 | } | |
224 | ||
225 | public override sbyte ReadByte() | |
226 | { | |
227 | return WrappedProtocol.ReadByte(); | |
228 | } | |
229 | ||
230 | public override short ReadI16() | |
231 | { | |
232 | return WrappedProtocol.ReadI16(); | |
233 | } | |
234 | ||
235 | public override int ReadI32() | |
236 | { | |
237 | return WrappedProtocol.ReadI32(); | |
238 | } | |
239 | ||
240 | public override long ReadI64() | |
241 | { | |
242 | return WrappedProtocol.ReadI64(); | |
243 | } | |
244 | ||
245 | public override double ReadDouble() | |
246 | { | |
247 | return WrappedProtocol.ReadDouble(); | |
248 | } | |
249 | ||
250 | public override string ReadString() | |
251 | { | |
252 | return WrappedProtocol.ReadString(); | |
253 | } | |
254 | ||
255 | public override byte[] ReadBinary() | |
256 | { | |
257 | return WrappedProtocol.ReadBinary(); | |
258 | } | |
259 | } | |
260 | ||
261 | } |