1919#include < bsls_ident.h>
2020BSLS_IDENT (" $Id: $" )
2121
22+ #include < ntca_compressiontype.h>
23+ #include < ntca_sendtoken.h>
2224#include < ntccfg_platform.h>
2325#include < ntcscm_version.h>
2426#include < ntsa_error.h>
27+ #include < bdlb_nullablevalue.h>
2528#include < bslh_hash.h>
2629#include < bsl_iosfwd.h>
2730
@@ -33,6 +36,23 @@ namespace ntca {
3336// / @par Attributes
3437// / This class is composed of the following attributes.
3538// /
39+ // / @li @b token:
40+ // / The token used to cancel the operation. This token matches the token
41+ // / specified in the corresponding send options, if any.
42+ // /
43+ // / @li @b compressionType:
44+ // / The compression algorithm used to deflate the user's data before
45+ // / transmission, if any. If unspecified, no compression was performed.
46+ // /
47+ // / @li @b compressionRatio:
48+ // / The ratio of deflated size of the data actually transmitted to the size of
49+ // / the original data desired to be sent. Note that value may be greater than
50+ // / one in the case of poorly-compressible data. If unspecified, no compression
51+ // / was performed.
52+ // /
53+ // / @li @b error:
54+ // / The error detected when performing the operation.
55+ // /
3656// / @li @b error:
3757// / The error detected when performing the operation.
3858// /
@@ -42,7 +62,10 @@ namespace ntca {
4262// / @ingroup module_ntci_operation_send
4363class SendContext
4464{
45- ntsa::Error d_error;
65+ bdlb::NullableValue<ntca::SendToken> d_token;
66+ bdlb::NullableValue<ntca::CompressionType::Value> d_compressionType;
67+ bdlb::NullableValue<double > d_compressionRatio;
68+ ntsa::Error d_error;
4669
4770 public:
4871 // / Create a new send context having the default value.
@@ -55,40 +78,61 @@ class SendContext
5578 // / Destroy this object.
5679 ~SendContext ();
5780
58- // / Assign the value of the specified 'other' object to this object.
59- // / Return a reference to this modifiable object.
81+ // / Assign the value of the specified 'other' object to this object. Return
82+ // / a reference to this modifiable object.
6083 SendContext& operator =(const SendContext& other);
6184
62- // / Reset the value of this object to its value upon default
63- // / construction.
85+ // / Reset the value of this object to its value upon default construction.
6486 void reset ();
6587
66- // / Set the error detected when performing the operation to the
67- // / specified 'value'.
88+ // / Set the token used to cancel the operation to the specified 'value'.
89+ void setToken (const ntca::SendToken& value);
90+
91+ // / Set the compression algorithm compression algorithm used to deflate the
92+ // / user's data before transmission to the specified 'value'.
93+ void setCompressionType (ntca::CompressionType::Value value);
94+
95+ // / Set the ratio of deflated size of the data actually transmitted to the
96+ // / size of the original data desired to be sent to the specified 'value'.
97+ void setCompressionRatio (double value);
98+
99+ // / Set the error detected when performing the operation to the specified
100+ // / 'value'.
68101 void setError (const ntsa::Error& value);
69102
103+ // / Return the token used to cancel the operation.
104+ const bdlb::NullableValue<ntca::SendToken>& token () const ;
105+
106+ // / Return the compression algorithm compression algorithm used to deflate
107+ // / the user's data before transmission.
108+ const bdlb::NullableValue<ntca::CompressionType::Value>&
109+ compressionType () const ;
110+
111+ // / Return the ratio of deflated size of the data actually transmitted to
112+ // / the size of the original data desired to be sent.
113+ const bdlb::NullableValue<double >& compressionRatio () const ;
114+
70115 // / Return the error detected when performing the operation.
71116 const ntsa::Error& error () const ;
72117
73- // / Return true if this object has the same value as the specified
74- // / 'other' object, otherwise return false.
118+ // / Return true if this object has the same value as the specified 'other'
119+ // / object, otherwise return false.
75120 bool equals (const SendContext& other) const ;
76121
77- // / Return true if the value of this object is less than the value of
78- // / the specified 'other' object, otherwise return false.
122+ // / Return true if the value of this object is less than the value of the
123+ // / specified 'other' object, otherwise return false.
79124 bool less (const SendContext& other) const ;
80125
81- // / Format this object to the specified output 'stream' at the
82- // / optionally specified indentation 'level' and return a reference to
83- // / the modifiable 'stream'. If 'level' is specified, optionally
84- // / specify 'spacesPerLevel', the number of spaces per indentation level
85- // / for this and all of its nested objects. Each line is indented by
86- // / the absolute value of 'level * spacesPerLevel'. If 'level' is
87- // / negative, suppress indentation of the first line. If
88- // / 'spacesPerLevel' is negative, suppress line breaks and format the
89- // / entire output on one line. If 'stream' is initially invalid, this
90- // / operation has no effect. Note that a trailing newline is provided
91- // / in multiline mode only.
126+ // / Format this object to the specified output 'stream' at the optionally
127+ // / specified indentation 'level' and return a reference to the modifiable
128+ // / 'stream'. If 'level' is specified, optionally specify
129+ // / 'spacesPerLevel', the number of spaces per indentation level for this
130+ // / and all of its nested objects. Each line is indented by the absolute
131+ // / value of 'level * spacesPerLevel'. If 'level' is negative, suppress
132+ // / indentation of the first line. If 'spacesPerLevel' is negative,
133+ // / suppress line breaks and format the entire output on one line. If
134+ // / 'stream' is initially invalid, this operation has no effect. Note that
135+ // / a trailing newline is provided in multiline mode only.
92136 bsl::ostream& print (bsl::ostream& stream,
93137 int level = 0 ,
94138 int spacesPerLevel = 4 ) const ;
@@ -137,13 +181,19 @@ void hashAppend(HASH_ALGORITHM& algorithm, const SendContext& value);
137181
138182NTCCFG_INLINE
139183SendContext::SendContext ()
140- : d_error()
184+ : d_token()
185+ , d_compressionType()
186+ , d_compressionRatio()
187+ , d_error()
141188{
142189}
143190
144191NTCCFG_INLINE
145192SendContext::SendContext (const SendContext& original)
146- : d_error(original.d_error)
193+ : d_token(original.d_token)
194+ , d_compressionType(original.d_compressionType)
195+ , d_compressionRatio(original.d_compressionRatio)
196+ , d_error(original.d_error)
147197{
148198}
149199
@@ -155,22 +205,68 @@ SendContext::~SendContext()
155205NTCCFG_INLINE
156206SendContext& SendContext::operator =(const SendContext& other)
157207{
158- d_error = other.d_error ;
208+ if (this != &other) {
209+ d_token = other.d_token ;
210+ d_compressionType = other.d_compressionType ;
211+ d_compressionRatio = other.d_compressionRatio ;
212+ d_error = other.d_error ;
213+ }
214+
159215 return *this ;
160216}
161217
162218NTCCFG_INLINE
163219void SendContext::reset ()
164220{
221+ d_token.reset ();
222+ d_compressionType.reset ();
223+ d_compressionRatio.reset ();
165224 d_error = ntsa::Error ();
166225}
167226
227+ NTCCFG_INLINE
228+ void SendContext::setToken (const ntca::SendToken& value)
229+ {
230+ d_token = value;
231+ }
232+
233+ NTCCFG_INLINE
234+ void SendContext::setCompressionType (ntca::CompressionType::Value value)
235+ {
236+ d_compressionType = value;
237+ }
238+
239+ NTCCFG_INLINE
240+ void SendContext::setCompressionRatio (double value)
241+ {
242+ d_compressionRatio = value;
243+ }
244+
168245NTCCFG_INLINE
169246void SendContext::setError (const ntsa::Error& value)
170247{
171248 d_error = value;
172249}
173250
251+ NTCCFG_INLINE
252+ const bdlb::NullableValue<ntca::SendToken>& SendContext::token () const
253+ {
254+ return d_token;
255+ }
256+
257+ NTCCFG_INLINE
258+ const bdlb::NullableValue<ntca::CompressionType::Value>&
259+ SendContext::compressionType () const
260+ {
261+ return d_compressionType;
262+ }
263+
264+ NTCCFG_INLINE
265+ const bdlb::NullableValue<double >& SendContext::compressionRatio () const
266+ {
267+ return d_compressionRatio;
268+ }
269+
174270NTCCFG_INLINE
175271const ntsa::Error& SendContext::error () const
176272{
@@ -206,6 +302,9 @@ void hashAppend(HASH_ALGORITHM& algorithm, const SendContext& value)
206302{
207303 using bslh::hashAppend;
208304
305+ hashAppend (algorithm, value.token ());
306+ hashAppend (algorithm, value.compressionType ());
307+ hashAppend (algorithm, value.compressionRatio ());
209308 hashAppend (algorithm, value.error ());
210309}
211310
0 commit comments