BDE 4.14.0 Production release
Loading...
Searching...
No Matches
s_baltst_timingrequest.h
Go to the documentation of this file.
1/// @file s_baltst_timingrequest.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_timingrequest.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_TIMINGREQUEST
9#define INCLUDED_S_BALTST_TIMINGREQUEST
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_timingrequest_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_timingrequest s_baltst_timingrequest
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_timingrequest
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_timingrequest-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_timingrequest-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_timingrequest
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
59#include <s_baltst_bigrecord.h>
60
61#include <s_baltst_sqrt.h>
62
63#include <bsl_iosfwd.h>
64#include <bsl_limits.h>
65
66
67
68namespace bslma { class Allocator; }
69
70namespace s_baltst { class TimingRequest; }
71namespace s_baltst {
72
73 // ===================
74 // class TimingRequest
75 // ===================
76
77/// A choice record representative of a typical request object.
78///
79/// See @ref s_baltst_timingrequest
81
82 // INSTANCE DATA
83 union {
87 };
88
89 int d_selectionId;
90 bslma::Allocator *d_allocator_p;
91
92 public:
93 // TYPES
94
95 enum {
100 };
101
102 enum {
104 };
105
106 enum {
110 };
111
112 // CONSTANTS
113 static const char CLASS_NAME[];
114
116
117 // CLASS METHODS
118
119 /// Return selection information for the selection indicated by the
120 /// specified `id` if the selection exists, and 0 otherwise.
122
123 /// Return selection information for the selection indicated by the
124 /// specified `name` of the specified `nameLength` if the selection
125 /// exists, and 0 otherwise.
127 const char *name,
128 int nameLength);
129
130 // CREATORS
131
132 /// Create an object of type `TimingRequest` having the default value.
133 /// Use the optionally specified `basicAllocator` to supply memory. If
134 /// `basicAllocator` is 0, the currently installed default allocator is
135 /// used.
136 explicit TimingRequest(bslma::Allocator *basicAllocator = 0);
137
138 /// Create an object of type `TimingRequest` having the value of the
139 /// specified `original` object. Use the optionally specified
140 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
141 /// currently installed default allocator is used.
143 bslma::Allocator *basicAllocator = 0);
144
145#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
146 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
147 /// Create an object of type `TimingRequest` having the value of the
148 /// specified `original` object. After performing this action, the
149 /// `original` object will be left in a valid, but unspecified state.
150 TimingRequest(TimingRequest&& original) noexcept;
151
152 /// Create an object of type `TimingRequest` having the value of the
153 /// specified `original` object. After performing this action, the
154 /// `original` object will be left in a valid, but unspecified state.
155 /// Use the optionally specified `basicAllocator` to supply memory. If
156 /// `basicAllocator` is 0, the currently installed default allocator is
157 /// used.
158 TimingRequest(TimingRequest&& original,
159 bslma::Allocator *basicAllocator);
160#endif
161
162 /// Destroy this object.
164
165 // MANIPULATORS
166
167 /// Assign to this object the value of the specified `rhs` object.
169
170#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
171 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
172 /// Assign to this object the value of the specified `rhs` object.
173 /// After performing this action, the `rhs` object will be left in a
174 /// valid, but unspecified state.
176#endif
177
178 /// Reset this object to the default value (i.e., its value upon default
179 /// construction).
180 void reset();
181
182 /// Set the value of this object to be the default for the selection
183 /// indicated by the specified `selectionId`. Return 0 on success, and
184 /// non-zero value otherwise (i.e., the selection is not found).
186
187 /// Set the value of this object to be the default for the selection
188 /// indicated by the specified `name` of the specified `nameLength`.
189 /// Return 0 on success, and non-zero value otherwise (i.e., the
190 /// selection is not found).
191 int makeSelection(const char *name, int nameLength);
192
195#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
196 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
198#endif
199 // Set the value of this object to be a "Sqrt" value. Optionally
200 // specify the 'value' of the "Sqrt". If 'value' is not specified, the
201 // default "Sqrt" value is used.
202
205#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
206 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
208#endif
209 // Set the value of this object to be a "Basic" value. Optionally
210 // specify the 'value' of the "Basic". If 'value' is not specified,
211 // the default "Basic" value is used.
212
215#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
216 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
218#endif
219 // Set the value of this object to be a "Big" value. Optionally
220 // specify the 'value' of the "Big". If 'value' is not specified, the
221 // default "Big" value is used.
222
223 /// Invoke the specified `manipulator` on the address of the modifiable
224 /// selection, supplying `manipulator` with the corresponding selection
225 /// information structure. Return the value returned from the
226 /// invocation of `manipulator` if this object has a defined selection,
227 /// and -1 otherwise.
228 template<class MANIPULATOR>
229 int manipulateSelection(MANIPULATOR& manipulator);
230
231 /// Return a reference to the modifiable "Sqrt" selection of this object
232 /// if "Sqrt" is the current selection. The behavior is undefined
233 /// unless "Sqrt" is the selection of this object.
235
236 /// Return a reference to the modifiable "Basic" selection of this
237 /// object if "Basic" is the current selection. The behavior is
238 /// undefined unless "Basic" is the selection of this object.
240
241 /// Return a reference to the modifiable "Big" selection of this object
242 /// if "Big" is the current selection. The behavior is undefined unless
243 /// "Big" is the selection of this object.
245
246 // ACCESSORS
247
248 /// Format this object to the specified output `stream` at the
249 /// optionally specified indentation `level` and return a reference to
250 /// the modifiable `stream`. If `level` is specified, optionally
251 /// specify `spacesPerLevel`, the number of spaces per indentation level
252 /// for this and all of its nested objects. Each line is indented by
253 /// the absolute value of `level * spacesPerLevel`. If `level` is
254 /// negative, suppress indentation of the first line. If
255 /// `spacesPerLevel` is negative, suppress line breaks and format the
256 /// entire output on one line. If `stream` is initially invalid, this
257 /// operation has no effect. Note that a trailing newline is provided
258 /// in multiline mode only.
259 bsl::ostream& print(bsl::ostream& stream,
260 int level = 0,
261 int spacesPerLevel = 4) const;
262
263 /// Return the id of the current selection if the selection is defined,
264 /// and -1 otherwise.
265 int selectionId() const;
266
267 /// Invoke the specified `accessor` on the non-modifiable selection,
268 /// supplying `accessor` with the corresponding selection information
269 /// structure. Return the value returned from the invocation of
270 /// `accessor` if this object has a defined selection, and -1 otherwise.
271 template<class ACCESSOR>
272 int accessSelection(ACCESSOR& accessor) const;
273
274 /// Return a reference to the non-modifiable "Sqrt" selection of this
275 /// object if "Sqrt" is the current selection. The behavior is
276 /// undefined unless "Sqrt" is the selection of this object.
277 const s_baltst::Sqrt& sqrt() const;
278
279 /// Return a reference to the non-modifiable "Basic" selection of this
280 /// object if "Basic" is the current selection. The behavior is
281 /// undefined unless "Basic" is the selection of this object.
282 const s_baltst::BasicRecord& basic() const;
283
284 /// Return a reference to the non-modifiable "Big" selection of this
285 /// object if "Big" is the current selection. The behavior is undefined
286 /// unless "Big" is the selection of this object.
287 const s_baltst::BigRecord& big() const;
288
289 /// Return `true` if the value of this object is a "Sqrt" value, and
290 /// return `false` otherwise.
291 bool isSqrtValue() const;
292
293 /// Return `true` if the value of this object is a "Basic" value, and
294 /// return `false` otherwise.
295 bool isBasicValue() const;
296
297 /// Return `true` if the value of this object is a "Big" value, and
298 /// return `false` otherwise.
299 bool isBigValue() const;
300
301 /// Return `true` if the value of this object is undefined, and `false`
302 /// otherwise.
303 bool isUndefinedValue() const;
304
305 /// Return the symbolic name of the current selection of this object.
306 const char *selectionName() const;
307};
308
309// FREE OPERATORS
310
311/// Return `true` if the specified `lhs` and `rhs` objects have the same
312/// value, and `false` otherwise. Two `TimingRequest` objects have the same
313/// value if either the selections in both objects have the same ids and
314/// the same values, or both selections are undefined.
315inline
316bool operator==(const TimingRequest& lhs, const TimingRequest& rhs);
317
318/// Return `true` if the specified `lhs` and `rhs` objects do not have the
319/// same values, as determined by `operator==`, and `false` otherwise.
320inline
321bool operator!=(const TimingRequest& lhs, const TimingRequest& rhs);
322
323/// Format the specified `rhs` to the specified output `stream` and
324/// return a reference to the modifiable `stream`.
325inline
326bsl::ostream& operator<<(bsl::ostream& stream, const TimingRequest& rhs);
327
328} // close package namespace
329
330// TRAITS
331
333
334// ============================================================================
335// INLINE FUNCTION DEFINITIONS
336// ============================================================================
337
338namespace s_baltst {
339
340 // -------------------
341 // class TimingRequest
342 // -------------------
343
344// CLASS METHODS
345// CREATORS
346inline
348: d_selectionId(SELECTION_ID_UNDEFINED)
349, d_allocator_p(bslma::Default::allocator(basicAllocator))
350{
351}
352
353inline
358
359// MANIPULATORS
360template <class MANIPULATOR>
361int TimingRequest::manipulateSelection(MANIPULATOR& manipulator)
362{
363 switch (d_selectionId) {
365 return manipulator(&d_sqrt.object(),
368 return manipulator(&d_basic.object(),
371 return manipulator(&d_big.object(),
373 default:
375 return -1;
376 }
377}
378
379inline
381{
382 BSLS_ASSERT(SELECTION_ID_SQRT == d_selectionId);
383 return d_sqrt.object();
384}
385
386inline
392
393inline
395{
396 BSLS_ASSERT(SELECTION_ID_BIG == d_selectionId);
397 return d_big.object();
398}
399
400// ACCESSORS
401inline
403{
404 return d_selectionId;
405}
406
407template <class ACCESSOR>
408int TimingRequest::accessSelection(ACCESSOR& accessor) const
409{
410 switch (d_selectionId) {
412 return accessor(d_sqrt.object(),
415 return accessor(d_basic.object(),
417 case SELECTION_ID_BIG:
418 return accessor(d_big.object(),
420 default:
421 BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId);
422 return -1;
423 }
424}
425
426inline
428{
429 BSLS_ASSERT(SELECTION_ID_SQRT == d_selectionId);
430 return d_sqrt.object();
431}
432
433inline
435{
436 BSLS_ASSERT(SELECTION_ID_BASIC == d_selectionId);
437 return d_basic.object();
438}
439
440inline
442{
443 BSLS_ASSERT(SELECTION_ID_BIG == d_selectionId);
444 return d_big.object();
445}
446
447inline
449{
450 return SELECTION_ID_SQRT == d_selectionId;
451}
452
453inline
455{
456 return SELECTION_ID_BASIC == d_selectionId;
457}
458
459inline
461{
462 return SELECTION_ID_BIG == d_selectionId;
463}
464
465inline
467{
468 return SELECTION_ID_UNDEFINED == d_selectionId;
469}
470} // close package namespace
471
472// FREE FUNCTIONS
473
474inline
476 const s_baltst::TimingRequest& lhs,
477 const s_baltst::TimingRequest& rhs)
478{
479 typedef s_baltst::TimingRequest Class;
480 if (lhs.selectionId() == rhs.selectionId()) {
481 switch (rhs.selectionId()) {
482 case Class::SELECTION_ID_SQRT:
483 return lhs.sqrt() == rhs.sqrt();
484 case Class::SELECTION_ID_BASIC:
485 return lhs.basic() == rhs.basic();
486 case Class::SELECTION_ID_BIG:
487 return lhs.big() == rhs.big();
488 default:
489 BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId());
490 return true;
491 }
492 }
493 else {
494 return false;
495 }
496}
497
498inline
500 const s_baltst::TimingRequest& lhs,
501 const s_baltst::TimingRequest& rhs)
502{
503 return !(lhs == rhs);
504}
505
506inline
507bsl::ostream& s_baltst::operator<<(
508 bsl::ostream& stream,
509 const s_baltst::TimingRequest& rhs)
510{
511 return rhs.print(stream, 0, -1);
512}
513
514
515#endif
516
517// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
518// USING bas_codegen.pl s_baltst_timingrequest.xsd --mode msg --includedir . --msgComponent timingrequest --noRecurse --noExternalization --noHashSupport --noAggregateConversion
519// ----------------------------------------------------------------------------
520// NOTICE:
521// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
522// Property of Bloomberg Finance L.P. (BFLP)
523// This software is made available solely pursuant to the
524// terms of a BFLP license agreement which governs its use.
525// ------------------------------- END-OF-FILE --------------------------------
526
527/** @} */
528/** @} */
529/** @} */
Definition bslma_allocator.h:457
Definition s_baltst_basicrecord.h:78
Definition s_baltst_bigrecord.h:80
Definition s_baltst_sqrt.h:70
Definition s_baltst_timingrequest.h:80
TimingRequest & operator=(const TimingRequest &rhs)
Assign to this object the value of the specified rhs object.
int makeSelection(const char *name, int nameLength)
bool isUndefinedValue() const
Definition s_baltst_timingrequest.h:466
bsls::ObjectBuffer< s_baltst::Sqrt > d_sqrt
Definition s_baltst_timingrequest.h:84
static const char CLASS_NAME[]
Definition s_baltst_timingrequest.h:113
static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[]
Definition s_baltst_timingrequest.h:115
s_baltst::Sqrt & makeSqrt(const s_baltst::Sqrt &value)
const char * selectionName() const
Return the symbolic name of the current selection of this object.
s_baltst::BasicRecord & basic()
Definition s_baltst_timingrequest.h:387
s_baltst::Sqrt & makeSqrt()
bool isSqrtValue() const
Definition s_baltst_timingrequest.h:448
int selectionId() const
Definition s_baltst_timingrequest.h:402
static const bdlat_SelectionInfo * lookupSelectionInfo(const char *name, int nameLength)
bsls::ObjectBuffer< s_baltst::BasicRecord > d_basic
Definition s_baltst_timingrequest.h:85
bsls::ObjectBuffer< s_baltst::BigRecord > d_big
Definition s_baltst_timingrequest.h:86
s_baltst::BasicRecord & makeBasic(const s_baltst::BasicRecord &value)
@ SELECTION_INDEX_BASIC
Definition s_baltst_timingrequest.h:108
@ SELECTION_INDEX_SQRT
Definition s_baltst_timingrequest.h:107
@ SELECTION_INDEX_BIG
Definition s_baltst_timingrequest.h:109
s_baltst::BigRecord & makeBig(const s_baltst::BigRecord &value)
int accessSelection(ACCESSOR &accessor) const
Definition s_baltst_timingrequest.h:408
TimingRequest(const TimingRequest &original, bslma::Allocator *basicAllocator=0)
TimingRequest(bslma::Allocator *basicAllocator=0)
Definition s_baltst_timingrequest.h:347
s_baltst::BasicRecord & makeBasic()
s_baltst::BigRecord & makeBig()
bool isBasicValue() const
Definition s_baltst_timingrequest.h:454
static const bdlat_SelectionInfo * lookupSelectionInfo(int id)
s_baltst::Sqrt & sqrt()
Definition s_baltst_timingrequest.h:380
@ NUM_SELECTIONS
Definition s_baltst_timingrequest.h:103
bool isBigValue() const
Definition s_baltst_timingrequest.h:460
s_baltst::BigRecord & big()
Definition s_baltst_timingrequest.h:394
int manipulateSelection(MANIPULATOR &manipulator)
Definition s_baltst_timingrequest.h:361
int makeSelection(int selectionId)
@ SELECTION_ID_UNDEFINED
Definition s_baltst_timingrequest.h:96
@ SELECTION_ID_BASIC
Definition s_baltst_timingrequest.h:98
@ SELECTION_ID_SQRT
Definition s_baltst_timingrequest.h:97
@ SELECTION_ID_BIG
Definition s_baltst_timingrequest.h:99
~TimingRequest()
Destroy this object.
Definition s_baltst_timingrequest.h:354
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
#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