BDE 4.14.0 Production release
Loading...
Searching...
No Matches
s_baltst_request.h
Go to the documentation of this file.
1/// @file s_baltst_request.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_request.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_REQUEST
9#define INCLUDED_S_BALTST_REQUEST
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_request_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_request s_baltst_request
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_request
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_request-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_request-purpose}
28/// Provide value-semantic attribute classes
29/// @}
30/** @} */
31/** @} */
32
33/** @addtogroup Standalones
34 * @{
35 */
36/** @addtogroup s_baltst
37 * @{
38 */
39/** @addtogroup s_baltst_request
40 * @{
41 */
42
43#include <bslalg_typetraits.h>
44
45#include <bdlat_attributeinfo.h>
46
47#include <bdlat_selectioninfo.h>
48
49#include <bdlat_typetraits.h>
50
51#include <bsls_objectbuffer.h>
52
53#include <bslma_default.h>
54
55#include <bsls_assert.h>
56
58
60
61#include <bsl_iosfwd.h>
62#include <bsl_limits.h>
63
64
65
66namespace bslma { class Allocator; }
67
68namespace s_baltst { class Request; }
69namespace s_baltst {
70
71 // =============
72 // class Request
73 // =============
74
75class Request {
76
77 // INSTANCE DATA
78 union {
81 };
82
83 int d_selectionId;
84 bslma::Allocator *d_allocator_p;
85
86 public:
87 // TYPES
88
89 enum {
93 };
94
95 enum {
97 };
98
99 enum {
102 };
103
104 // CONSTANTS
105 static const char CLASS_NAME[];
106
108
109 // CLASS METHODS
110
111 /// Return selection information for the selection indicated by the
112 /// specified `id` if the selection exists, and 0 otherwise.
114
115 /// Return selection information for the selection indicated by the
116 /// specified `name` of the specified `nameLength` if the selection
117 /// exists, and 0 otherwise.
119 const char *name,
120 int nameLength);
121
122 // CREATORS
123
124 /// Create an object of type `Request` having the default value. Use
125 /// the optionally specified `basicAllocator` to supply memory. If
126 /// `basicAllocator` is 0, the currently installed default allocator is
127 /// used.
128 explicit Request(bslma::Allocator *basicAllocator = 0);
129
130 /// Create an object of type `Request` having the value of the specified
131 /// `original` object. Use the optionally specified `basicAllocator` to
132 /// supply memory. If `basicAllocator` is 0, the currently installed
133 /// default allocator is used.
134 Request(const Request& original,
135 bslma::Allocator *basicAllocator = 0);
136
137#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
138 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
139 /// Create an object of type `Request` having the value of the specified
140 /// `original` object. After performing this action, the `original`
141 /// object will be left in a valid, but unspecified state.
142 Request(Request&& original) noexcept;
143
144 /// Create an object of type `Request` having the value of the specified
145 /// `original` object. After performing this action, the `original`
146 /// object will be left in a valid, but unspecified state. Use the
147 /// optionally specified `basicAllocator` to supply memory. If
148 /// `basicAllocator` is 0, the currently installed default allocator is
149 /// used.
150 Request(Request&& original,
151 bslma::Allocator *basicAllocator);
152#endif
153
154 /// Destroy this object.
155 ~Request();
156
157 // MANIPULATORS
158
159 /// Assign to this object the value of the specified `rhs` object.
161
162#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
163 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
164 /// Assign to this object the value of the specified `rhs` object.
165 /// After performing this action, the `rhs` object will be left in a
166 /// valid, but unspecified state.
167 Request& operator=(Request&& rhs);
168#endif
169
170 /// Reset this object to the default value (i.e., its value upon default
171 /// construction).
172 void reset();
173
174 /// Set the value of this object to be the default for the selection
175 /// indicated by the specified `selectionId`. Return 0 on success, and
176 /// non-zero value otherwise (i.e., the selection is not found).
178
179 /// Set the value of this object to be the default for the selection
180 /// indicated by the specified `name` of the specified `nameLength`.
181 /// Return 0 on success, and non-zero value otherwise (i.e., the
182 /// selection is not found).
183 int makeSelection(const char *name, int nameLength);
184
187#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
188 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
190#endif
191 // Set the value of this object to be a "SimpleRequest" value.
192 // Optionally specify the 'value' of the "SimpleRequest". If 'value'
193 // is not specified, the default "SimpleRequest" value is used.
194
197#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
198 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
200#endif
201 // Set the value of this object to be a "FeatureRequest" value.
202 // Optionally specify the 'value' of the "FeatureRequest". If 'value'
203 // is not specified, the default "FeatureRequest" value is used.
204
205 /// Invoke the specified `manipulator` on the address of the modifiable
206 /// selection, supplying `manipulator` with the corresponding selection
207 /// information structure. Return the value returned from the
208 /// invocation of `manipulator` if this object has a defined selection,
209 /// and -1 otherwise.
210 template<class MANIPULATOR>
211 int manipulateSelection(MANIPULATOR& manipulator);
212
213 /// Return a reference to the modifiable "SimpleRequest" selection of
214 /// this object if "SimpleRequest" is the current selection. The
215 /// behavior is undefined unless "SimpleRequest" is the selection of
216 /// this object.
218
219 /// Return a reference to the modifiable "FeatureRequest" selection of
220 /// this object if "FeatureRequest" is the current selection. The
221 /// behavior is undefined unless "FeatureRequest" is the selection of
222 /// this object.
224
225 // ACCESSORS
226
227 /// Format this object to the specified output `stream` at the
228 /// optionally specified indentation `level` and return a reference to
229 /// the modifiable `stream`. If `level` is specified, optionally
230 /// specify `spacesPerLevel`, the number of spaces per indentation level
231 /// for this and all of its nested objects. Each line is indented by
232 /// the absolute value of `level * spacesPerLevel`. If `level` is
233 /// negative, suppress indentation of the first line. If
234 /// `spacesPerLevel` is negative, suppress line breaks and format the
235 /// entire output on one line. If `stream` is initially invalid, this
236 /// operation has no effect. Note that a trailing newline is provided
237 /// in multiline mode only.
238 bsl::ostream& print(bsl::ostream& stream,
239 int level = 0,
240 int spacesPerLevel = 4) const;
241
242 /// Return the id of the current selection if the selection is defined,
243 /// and -1 otherwise.
244 int selectionId() const;
245
246 /// Invoke the specified `accessor` on the non-modifiable selection,
247 /// supplying `accessor` with the corresponding selection information
248 /// structure. Return the value returned from the invocation of
249 /// `accessor` if this object has a defined selection, and -1 otherwise.
250 template<class ACCESSOR>
251 int accessSelection(ACCESSOR& accessor) const;
252
253 /// Return a reference to the non-modifiable "SimpleRequest" selection
254 /// of this object if "SimpleRequest" is the current selection. The
255 /// behavior is undefined unless "SimpleRequest" is the selection of
256 /// this object.
258
259 /// Return a reference to the non-modifiable "FeatureRequest" selection
260 /// of this object if "FeatureRequest" is the current selection. The
261 /// behavior is undefined unless "FeatureRequest" is the selection of
262 /// this object.
264
265 /// Return `true` if the value of this object is a "SimpleRequest"
266 /// value, and return `false` otherwise.
267 bool isSimpleRequestValue() const;
268
269 /// Return `true` if the value of this object is a "FeatureRequest"
270 /// value, and return `false` otherwise.
271 bool isFeatureRequestValue() const;
272
273 /// Return `true` if the value of this object is undefined, and `false`
274 /// otherwise.
275 bool isUndefinedValue() const;
276
277 /// Return the symbolic name of the current selection of this object.
278 const char *selectionName() const;
279};
280
281// FREE OPERATORS
282
283/// Return `true` if the specified `lhs` and `rhs` objects have the same
284/// value, and `false` otherwise. Two `Request` objects have the same
285/// value if either the selections in both objects have the same ids and
286/// the same values, or both selections are undefined.
287inline
288bool operator==(const Request& lhs, const Request& rhs);
289
290/// Return `true` if the specified `lhs` and `rhs` objects do not have the
291/// same values, as determined by `operator==`, and `false` otherwise.
292inline
293bool operator!=(const Request& lhs, const Request& rhs);
294
295/// Format the specified `rhs` to the specified output `stream` and
296/// return a reference to the modifiable `stream`.
297inline
298bsl::ostream& operator<<(bsl::ostream& stream, const Request& rhs);
299
300} // close package namespace
301
302// TRAITS
303
305
306// ============================================================================
307// INLINE FUNCTION DEFINITIONS
308// ============================================================================
309
310namespace s_baltst {
311
312 // -------------
313 // class Request
314 // -------------
315
316// CLASS METHODS
317// CREATORS
318inline
320: d_selectionId(SELECTION_ID_UNDEFINED)
321, d_allocator_p(bslma::Default::allocator(basicAllocator))
322{
323}
324
325inline
327{
328 reset();
329}
330
331// MANIPULATORS
332template <class MANIPULATOR>
333int Request::manipulateSelection(MANIPULATOR& manipulator)
334{
335 switch (d_selectionId) {
337 return manipulator(&d_simpleRequest.object(),
340 return manipulator(&d_featureRequest.object(),
342 default:
344 return -1;
345 }
346}
347
348inline
354
355inline
361
362// ACCESSORS
363inline
365{
366 return d_selectionId;
367}
368
369template <class ACCESSOR>
370int Request::accessSelection(ACCESSOR& accessor) const
371{
372 switch (d_selectionId) {
374 return accessor(d_simpleRequest.object(),
377 return accessor(d_featureRequest.object(),
379 default:
380 BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId);
381 return -1;
382 }
383}
384
385inline
391
392inline
398
399inline
401{
402 return SELECTION_ID_SIMPLE_REQUEST == d_selectionId;
403}
404
405inline
407{
408 return SELECTION_ID_FEATURE_REQUEST == d_selectionId;
409}
410
411inline
413{
414 return SELECTION_ID_UNDEFINED == d_selectionId;
415}
416} // close package namespace
417
418// FREE FUNCTIONS
419
420inline
422 const s_baltst::Request& lhs,
423 const s_baltst::Request& rhs)
424{
425 typedef s_baltst::Request Class;
426 if (lhs.selectionId() == rhs.selectionId()) {
427 switch (rhs.selectionId()) {
428 case Class::SELECTION_ID_SIMPLE_REQUEST:
429 return lhs.simpleRequest() == rhs.simpleRequest();
430 case Class::SELECTION_ID_FEATURE_REQUEST:
431 return lhs.featureRequest() == rhs.featureRequest();
432 default:
433 BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId());
434 return true;
435 }
436 }
437 else {
438 return false;
439 }
440}
441
442inline
444 const s_baltst::Request& lhs,
445 const s_baltst::Request& rhs)
446{
447 return !(lhs == rhs);
448}
449
450inline
451bsl::ostream& s_baltst::operator<<(
452 bsl::ostream& stream,
453 const s_baltst::Request& rhs)
454{
455 return rhs.print(stream, 0, -1);
456}
457
458
459#endif
460
461// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
462// USING bas_codegen.pl s_baltst_request.xsd --mode msg --includedir . --msgComponent request --noRecurse --noExternalization --noHashSupport --noAggregateConversion
463// ----------------------------------------------------------------------------
464// NOTICE:
465// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
466// Property of Bloomberg Finance L.P. (BFLP)
467// This software is made available solely pursuant to the
468// terms of a BFLP license agreement which governs its use.
469// ------------------------------- END-OF-FILE --------------------------------
470
471/** @} */
472/** @} */
473/** @} */
Definition bslma_allocator.h:457
Definition s_baltst_featuretestmessage.h:87
Definition s_baltst_request.h:75
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
const char * selectionName() const
Return the symbolic name of the current selection of this object.
bsls::ObjectBuffer< s_baltst::FeatureTestMessage > d_featureRequest
Definition s_baltst_request.h:80
@ NUM_SELECTIONS
Definition s_baltst_request.h:96
bsls::ObjectBuffer< s_baltst::SimpleRequest > d_simpleRequest
Definition s_baltst_request.h:79
static const bdlat_SelectionInfo * lookupSelectionInfo(const char *name, int nameLength)
int makeSelection(const char *name, int nameLength)
int accessSelection(ACCESSOR &accessor) const
Definition s_baltst_request.h:370
s_baltst::SimpleRequest & makeSimpleRequest()
int makeSelection(int selectionId)
bool isSimpleRequestValue() const
Definition s_baltst_request.h:400
s_baltst::FeatureTestMessage & makeFeatureRequest(const s_baltst::FeatureTestMessage &value)
s_baltst::SimpleRequest & simpleRequest()
Definition s_baltst_request.h:349
Request(bslma::Allocator *basicAllocator=0)
Definition s_baltst_request.h:319
Request(const Request &original, bslma::Allocator *basicAllocator=0)
int manipulateSelection(MANIPULATOR &manipulator)
Definition s_baltst_request.h:333
static const char CLASS_NAME[]
Definition s_baltst_request.h:105
@ SELECTION_INDEX_SIMPLE_REQUEST
Definition s_baltst_request.h:100
@ SELECTION_INDEX_FEATURE_REQUEST
Definition s_baltst_request.h:101
@ SELECTION_ID_SIMPLE_REQUEST
Definition s_baltst_request.h:91
@ SELECTION_ID_UNDEFINED
Definition s_baltst_request.h:90
@ SELECTION_ID_FEATURE_REQUEST
Definition s_baltst_request.h:92
static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[]
Definition s_baltst_request.h:107
bool isUndefinedValue() const
Definition s_baltst_request.h:412
s_baltst::SimpleRequest & makeSimpleRequest(const s_baltst::SimpleRequest &value)
~Request()
Destroy this object.
Definition s_baltst_request.h:326
static const bdlat_SelectionInfo * lookupSelectionInfo(int id)
Request & operator=(const Request &rhs)
Assign to this object the value of the specified rhs object.
int selectionId() const
Definition s_baltst_request.h:364
bool isFeatureRequestValue() const
Definition s_baltst_request.h:406
s_baltst::FeatureTestMessage & featureRequest()
Definition s_baltst_request.h:356
s_baltst::FeatureTestMessage & makeFeatureRequest()
Definition s_baltst_simplerequest.h:73
#define BDLAT_DECL_CHOICE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:249
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT_RCSID(tag, str)
Definition bsls_ident.h:260
#define BSLS_IDENT_PRAGMA_ONCE
Definition bsls_ident.h:310
Definition balxml_encoderoptions.h:68
Definition s_baltst_address.h:66
bool operator!=(const Address &lhs, const Address &rhs)
bool operator==(const Address &lhs, const Address &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const Address &rhs)
Definition bdlat_selectioninfo.h:136
TYPE & object()
Definition bsls_objectbuffer.h:351