19
19
#include < bsls_ident.h>
20
20
BSLS_IDENT (" $Id: $" )
21
21
22
+ #include < ntca_compressiontype.h>
22
23
#include < ntccfg_platform.h>
23
24
#include < ntcscm_version.h>
24
25
#include < ntsa_endpoint.h>
25
26
#include < ntsa_error.h>
27
+ #include < ntsa_handle.h>
26
28
#include < ntsa_transport.h>
27
29
#include < bdlb_nullablevalue.h>
28
30
#include < bslh_hash.h>
@@ -43,6 +45,19 @@ namespace ntca {
43
45
// / @li @b transport:
44
46
// / The transport the receiver.
45
47
// /
48
+ // / @li @b compressionType:
49
+ // / The compression algorithm used to inflate the user's data after reception,
50
+ // / if any. If unspecified, no compression was performed.
51
+ // /
52
+ // / @li @b compressionRatio:
53
+ // / The ratio of inflated size of the data to the size of the original data
54
+ // / actually received. Note that value may be greater than one in the case of
55
+ // / poorly-compressible data. If unspecified, no compression was performed.
56
+ // /
57
+ // / @li @b foreignHandle:
58
+ // / The foreign handle sent by the peer, if any. If a foreign handle is
59
+ // / defined, it is the receivers responsibility to close it.
60
+ // /
46
61
// / @li @b error:
47
62
// / The error detected when performing the operation.
48
63
// /
@@ -52,9 +67,12 @@ namespace ntca {
52
67
// / @ingroup module_ntci_operation_receive
53
68
class ReceiveContext
54
69
{
55
- bdlb::NullableValue<ntsa::Endpoint> d_endpoint;
56
- ntsa::Transport::Value d_transport;
57
- ntsa::Error d_error;
70
+ bdlb::NullableValue<ntsa::Endpoint> d_endpoint;
71
+ ntsa::Transport::Value d_transport;
72
+ bdlb::NullableValue<ntca::CompressionType::Value> d_compressionType;
73
+ bdlb::NullableValue<double > d_compressionRatio;
74
+ bdlb::NullableValue<ntsa::Handle > d_foreignHandle;
75
+ ntsa::Error d_error;
58
76
59
77
public:
60
78
// / Create a new receive context having the default value.
@@ -82,6 +100,17 @@ class ReceiveContext
82
100
// / Set the transport of the receiver to the specified 'value'.
83
101
void setTransport (ntsa::Transport::Value value);
84
102
103
+ // / Set the compression algorithm used to inflate the user's data after
104
+ // / reception to the specified 'value'.
105
+ void setCompressionType (ntca::CompressionType::Value value);
106
+
107
+ // / Set the ratio of inflated size of the data to the size of the original
108
+ // / data actually received to the specified 'value'.
109
+ void setCompressionRatio (double value);
110
+
111
+ // / Set the foreign handle sent by the peer to the specified 'value'.
112
+ void setForeignHandle (ntsa::Handle value);
113
+
85
114
// / Set the error detected when performing the operation to the
86
115
// / specified 'value'.
87
116
void setError (const ntsa::Error& value);
@@ -108,6 +137,18 @@ class ReceiveContext
108
137
// / the transport of the receiver.
109
138
ntsa::TransportProtocol::Value transportProtocol () const ;
110
139
140
+ // / Return the compression algorithm used to inflate the user's data after
141
+ // / reception.
142
+ const bdlb::NullableValue<ntca::CompressionType::Value>&
143
+ compressionType () const ;
144
+
145
+ // / Return the ratio of inflated size of the data to the size of the
146
+ // / original data actually received.
147
+ const bdlb::NullableValue<double >& compressionRatio () const ;
148
+
149
+ // / Return the foreign handle sent by the peer, if any.
150
+ const bdlb::NullableValue<ntsa::Handle >& foreignHandle () const ;
151
+
111
152
// / Return the error detected when performing the operation.
112
153
const ntsa::Error& error () const ;
113
154
@@ -180,6 +221,9 @@ NTCCFG_INLINE
180
221
ReceiveContext::ReceiveContext ()
181
222
: d_endpoint()
182
223
, d_transport(ntsa::Transport::e_UNDEFINED)
224
+ , d_compressionType()
225
+ , d_compressionRatio()
226
+ , d_foreignHandle()
183
227
, d_error()
184
228
{
185
229
}
@@ -188,6 +232,9 @@ NTCCFG_INLINE
188
232
ReceiveContext::ReceiveContext (const ReceiveContext& original)
189
233
: d_endpoint(original.d_endpoint)
190
234
, d_transport(original.d_transport)
235
+ , d_compressionType(original.d_compressionType)
236
+ , d_compressionRatio(original.d_compressionRatio)
237
+ , d_foreignHandle(original.d_foreignHandle)
191
238
, d_error(original.d_error)
192
239
{
193
240
}
@@ -200,9 +247,12 @@ ReceiveContext::~ReceiveContext()
200
247
NTCCFG_INLINE
201
248
ReceiveContext& ReceiveContext::operator =(const ReceiveContext& other)
202
249
{
203
- d_endpoint = other.d_endpoint ;
204
- d_transport = other.d_transport ;
205
- d_error = other.d_error ;
250
+ d_endpoint = other.d_endpoint ;
251
+ d_transport = other.d_transport ;
252
+ d_compressionType = other.d_compressionType ;
253
+ d_compressionRatio = other.d_compressionRatio ;
254
+ d_foreignHandle = other.d_foreignHandle ;
255
+ d_error = other.d_error ;
206
256
return *this ;
207
257
}
208
258
@@ -211,7 +261,10 @@ void ReceiveContext::reset()
211
261
{
212
262
d_endpoint.reset ();
213
263
d_transport = ntsa::Transport::e_UNDEFINED;
214
- d_error = ntsa::Error ();
264
+ d_compressionType.reset ();
265
+ d_compressionRatio.reset ();
266
+ d_foreignHandle.reset ();
267
+ d_error = ntsa::Error ();
215
268
}
216
269
217
270
NTCCFG_INLINE
@@ -226,6 +279,24 @@ void ReceiveContext::setTransport(ntsa::Transport::Value value)
226
279
d_transport = value;
227
280
}
228
281
282
+ NTCCFG_INLINE
283
+ void ReceiveContext::setCompressionType (ntca::CompressionType::Value value)
284
+ {
285
+ d_compressionType = value;
286
+ }
287
+
288
+ NTCCFG_INLINE
289
+ void ReceiveContext::setCompressionRatio (double value)
290
+ {
291
+ d_compressionRatio = value;
292
+ }
293
+
294
+ NTCCFG_INLINE
295
+ void ReceiveContext::setForeignHandle (ntsa::Handle value)
296
+ {
297
+ d_foreignHandle = value;
298
+ }
299
+
229
300
NTCCFG_INLINE
230
301
void ReceiveContext::setError (const ntsa::Error& value)
231
302
{
@@ -262,6 +333,25 @@ ntsa::TransportProtocol::Value ReceiveContext::transportProtocol() const
262
333
return ntsa::Transport::getProtocol (d_transport);
263
334
}
264
335
336
+ NTCCFG_INLINE
337
+ const bdlb::NullableValue<ntca::CompressionType::Value>&
338
+ ReceiveContext::compressionType () const
339
+ {
340
+ return d_compressionType;
341
+ }
342
+
343
+ NTCCFG_INLINE
344
+ const bdlb::NullableValue<double >& ReceiveContext::compressionRatio () const
345
+ {
346
+ return d_compressionRatio;
347
+ }
348
+
349
+ NTCCFG_INLINE
350
+ const bdlb::NullableValue<ntsa::Handle >& ReceiveContext::foreignHandle () const
351
+ {
352
+ return d_foreignHandle;
353
+ }
354
+
265
355
NTCCFG_INLINE
266
356
const ntsa::Error& ReceiveContext::error () const
267
357
{
@@ -299,6 +389,9 @@ void hashAppend(HASH_ALGORITHM& algorithm, const ReceiveContext& value)
299
389
300
390
hashAppend (algorithm, value.endpoint ());
301
391
hashAppend (algorithm, value.transport ());
392
+ hashAppend (algorithm, value.compressionType ());
393
+ hashAppend (algorithm, value.compressionRatio ());
394
+ hashAppend (algorithm, value.foreignHandle ());
302
395
hashAppend (algorithm, value.error ());
303
396
}
304
397
0 commit comments