BDE 4.39.x 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 // PRIVATE ACCESSORS
93 bool isEqualTo(const TimingRequest& rhs) const;
94
95 public:
96 // TYPES
97
98 enum {
103 };
104
105 enum {
107 };
108
109 enum {
113 };
114
115 // CONSTANTS
116 static const char CLASS_NAME[];
117
119
120 // CLASS METHODS
121
122 /// Return selection information for the selection indicated by the
123 /// specified `id` if the selection exists, and 0 otherwise.
125
126 /// Return selection information for the selection indicated by the
127 /// specified `name` of the specified `nameLength` if the selection
128 /// exists, and 0 otherwise.
130 const char *name,
131 int nameLength);
132
133 // CREATORS
134
135 /// Create an object of type `TimingRequest` having the default value.
136 /// Use the optionally specified `basicAllocator` to supply memory. If
137 /// `basicAllocator` is 0, the currently installed default allocator is
138 /// used.
139 explicit TimingRequest(bslma::Allocator *basicAllocator = 0);
140
141 /// Create an object of type `TimingRequest` having the value of the
142 /// specified `original` object. Use the optionally specified
143 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
144 /// currently installed default allocator is used.
146 bslma::Allocator *basicAllocator = 0);
147
148#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
149 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
150 /// Create an object of type `TimingRequest` having the value of the
151 /// specified `original` object. After performing this action, the
152 /// `original` object will be left in a valid, but unspecified state.
153 TimingRequest(TimingRequest&& original) noexcept;
154
155 /// Create an object of type `TimingRequest` having the value of the
156 /// specified `original` object. After performing this action, the
157 /// `original` object will be left in a valid, but unspecified state.
158 /// Use the optionally specified `basicAllocator` to supply memory. If
159 /// `basicAllocator` is 0, the currently installed default allocator is
160 /// used.
161 TimingRequest(TimingRequest&& original,
162 bslma::Allocator *basicAllocator);
163#endif
164
165 /// Destroy this object.
167
168 // MANIPULATORS
169
170 /// Assign to this object the value of the specified `rhs` object.
172
173#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
174 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
175 /// Assign to this object the value of the specified `rhs` object.
176 /// After performing this action, the `rhs` object will be left in a
177 /// valid, but unspecified state.
179#endif
180
181 /// Reset this object to the default value (i.e., its value upon default
182 /// construction).
183 void reset();
184
185 /// Set the value of this object to be the default for the selection
186 /// indicated by the specified `selectionId`. Return 0 on success, and
187 /// non-zero value otherwise (i.e., the selection is not found).
189
190 /// Set the value of this object to be the default for the selection
191 /// indicated by the specified `name` of the specified `nameLength`.
192 /// Return 0 on success, and non-zero value otherwise (i.e., the
193 /// selection is not found).
194 int makeSelection(const char *name, int nameLength);
195
198#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
199 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
201#endif
202 // Set the value of this object to be a "Sqrt" value. Optionally
203 // specify the 'value' of the "Sqrt". If 'value' is not specified, the
204 // default "Sqrt" value is used.
205
208#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
209 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
211#endif
212 // Set the value of this object to be a "Basic" value. Optionally
213 // specify the 'value' of the "Basic". If 'value' is not specified,
214 // the default "Basic" value is used.
215
218#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
219 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
221#endif
222 // Set the value of this object to be a "Big" value. Optionally
223 // specify the 'value' of the "Big". If 'value' is not specified, the
224 // default "Big" value is used.
225
226 /// Invoke the specified `manipulator` on the address of the modifiable
227 /// selection, supplying `manipulator` with the corresponding selection
228 /// information structure. Return the value returned from the
229 /// invocation of `manipulator` if this object has a defined selection,
230 /// and -1 otherwise.
231 template <typename t_MANIPULATOR>
232 int manipulateSelection(t_MANIPULATOR& manipulator);
233
234 /// Return a reference to the modifiable "Sqrt" selection of this object
235 /// if "Sqrt" is the current selection.
236 ///
237 /// \pre The behavior is undefined unless "Sqrt" is the selection of this object.
239
240 /// Return a reference to the modifiable "Basic" selection of this
241 /// object if "Basic" is the current selection.
242 ///
243 /// \pre The behavior is undefined unless "Basic" is the selection of this object.
245
246 /// Return a reference to the modifiable "Big" selection of this object if "Big" is the current selection.
247 ///
248 /// \pre The behavior is undefined unless
249 /// "Big" is the selection of this object.
251
252 // ACCESSORS
253
254 /// Format this object to the specified output `stream` at the
255 /// optionally specified indentation `level` and return a reference to
256 /// the modifiable `stream`. If `level` is specified, optionally
257 /// specify `spacesPerLevel`, the number of spaces per indentation level
258 /// for this and all of its nested objects. Each line is indented by
259 /// the absolute value of `level * spacesPerLevel`. If `level` is
260 /// negative, suppress indentation of the first line. If
261 /// `spacesPerLevel` is negative, suppress line breaks and format the
262 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
263 ///
264 /// \note Note that a trailing newline is provided
265 /// in multiline mode only.
266 bsl::ostream& print(bsl::ostream& stream,
267 int level = 0,
268 int spacesPerLevel = 4) const;
269
270 /// Return the id of the current selection if the selection is defined,
271 /// and -1 otherwise.
272 int selectionId() const;
273
274 /// Invoke the specified `accessor` on the non-modifiable selection,
275 /// supplying `accessor` with the corresponding selection information
276 /// structure. Return the value returned from the invocation of
277 /// `accessor` if this object has a defined selection, and -1 otherwise.
278 template <typename t_ACCESSOR>
279 int accessSelection(t_ACCESSOR& accessor) const;
280
281 /// Return a reference to the non-modifiable "Sqrt" selection of this
282 /// object if "Sqrt" is the current selection.
283 ///
284 /// \pre The behavior is undefined unless "Sqrt" is the selection of this object.
285 const s_baltst::Sqrt& sqrt() const;
286
287 /// Return a reference to the non-modifiable "Basic" selection of this
288 /// object if "Basic" is the current selection.
289 ///
290 /// \pre The behavior is undefined unless "Basic" is the selection of this object.
291 const s_baltst::BasicRecord& basic() const;
292
293 /// Return a reference to the non-modifiable "Big" selection of this
294 /// object if "Big" is the current selection.
295 ///
296 /// \pre The behavior is undefined unless "Big" is the selection of this object.
297 const s_baltst::BigRecord& big() const;
298
299 /// Return `true` if the value of this object is a "Sqrt" value, and
300 /// return `false` otherwise.
301 bool isSqrtValue() const;
302
303 /// Return `true` if the value of this object is a "Basic" value, and
304 /// return `false` otherwise.
305 bool isBasicValue() const;
306
307 /// Return `true` if the value of this object is a "Big" value, and
308 /// return `false` otherwise.
309 bool isBigValue() const;
310
311 /// Return `true` if the value of this object is undefined, and `false`
312 /// otherwise.
313 bool isUndefinedValue() const;
314
315 /// Return the symbolic name of the current selection of this object.
316 const char *selectionName() const;
317
318 // HIDDEN FRIENDS
319
320 /// Return `true` if the specified `lhs` and `rhs` objects have the same
321 /// value, and `false` otherwise. Two `TimingRequest` objects have the
322 /// same value if either the selections in both objects have the same
323 /// ids and the same values, or both selections are undefined.
324 friend bool operator==(const TimingRequest& lhs, const TimingRequest& rhs)
325 {
326 return lhs.isEqualTo(rhs);
327 }
328
329 /// Return `true` if the specified `lhs` and `rhs` objects do not have
330 /// the same values, as determined by `operator==`, and `false`
331 /// otherwise.
332 friend bool operator!=(const TimingRequest& lhs, const TimingRequest& rhs)
333 {
334 return !(lhs == rhs);
335 }
336
337 /// Format the specified `rhs` to the specified output `stream` and
338 /// return a reference to the modifiable `stream`.
339 friend bsl::ostream& operator<<(bsl::ostream& stream,
340 const TimingRequest& rhs)
341 {
342 return rhs.print(stream, 0, -1);
343 }
344};
345
346} // close package namespace
347
348// TRAITS
349
351
352// ============================================================================
353// INLINE DEFINITIONS
354// ============================================================================
355
356namespace s_baltst {
357
358 // -------------------
359 // class TimingRequest
360 // -------------------
361
362// CLASS METHODS
363// PRIVATE ACCESSORS
364inline
365bool TimingRequest::isEqualTo(const TimingRequest& rhs) const
366{
367 typedef TimingRequest Class;
368 if (this->selectionId() == rhs.selectionId()) {
369 switch (rhs.selectionId()) {
370 case Class::SELECTION_ID_SQRT:
371 return this->sqrt() == rhs.sqrt();
372 case Class::SELECTION_ID_BASIC:
373 return this->basic() == rhs.basic();
374 case Class::SELECTION_ID_BIG:
375 return this->big() == rhs.big();
376 default:
377 BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId());
378 return true;
379 }
380 }
381 else {
382 return false;
383 }
384}
385
386// CREATORS
387inline
389: d_selectionId(SELECTION_ID_UNDEFINED)
390, d_allocator_p(bslma::Default::allocator(basicAllocator))
391{
392}
393
394inline
399
400// MANIPULATORS
401template <typename t_MANIPULATOR>
402int TimingRequest::manipulateSelection(t_MANIPULATOR& manipulator)
403{
404 switch (d_selectionId) {
406 return manipulator(&d_sqrt.object(),
409 return manipulator(&d_basic.object(),
412 return manipulator(&d_big.object(),
414 default:
416 return -1;
417 }
418}
419
420inline
422{
423 BSLS_ASSERT(SELECTION_ID_SQRT == d_selectionId);
424 return d_sqrt.object();
425}
426
427inline
433
434inline
436{
437 BSLS_ASSERT(SELECTION_ID_BIG == d_selectionId);
438 return d_big.object();
439}
440
441// ACCESSORS
442inline
444{
445 return d_selectionId;
446}
447
448template <typename t_ACCESSOR>
449int TimingRequest::accessSelection(t_ACCESSOR& accessor) const
450{
451 switch (d_selectionId) {
453 return accessor(d_sqrt.object(),
456 return accessor(d_basic.object(),
458 case SELECTION_ID_BIG:
459 return accessor(d_big.object(),
461 default:
462 BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId);
463 return -1;
464 }
465}
466
467inline
469{
470 BSLS_ASSERT(SELECTION_ID_SQRT == d_selectionId);
471 return d_sqrt.object();
472}
473
474inline
476{
477 BSLS_ASSERT(SELECTION_ID_BASIC == d_selectionId);
478 return d_basic.object();
479}
480
481inline
483{
484 BSLS_ASSERT(SELECTION_ID_BIG == d_selectionId);
485 return d_big.object();
486}
487
488inline
490{
491 return SELECTION_ID_SQRT == d_selectionId;
492}
493
494inline
496{
497 return SELECTION_ID_BASIC == d_selectionId;
498}
499
500inline
502{
503 return SELECTION_ID_BIG == d_selectionId;
504}
505
506inline
508{
509 return SELECTION_ID_UNDEFINED == d_selectionId;
510}
511} // close package namespace
512
513// FREE FUNCTIONS
514
515
516#endif
517
518// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
519// USING bas_codegen.pl s_baltst_timingrequest.xsd --mode msg --includedir . --msgComponent timingrequest --noRecurse --noExternalization --noHashSupport --noAggregateConversion
520// ----------------------------------------------------------------------------
521// NOTICE:
522// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
523// Property of Bloomberg Finance L.P. (BFLP)
524// This software is made available solely pursuant to the
525// terms of a BFLP license agreement which governs its use.
526// ------------------------------- END-OF-FILE --------------------------------
527
528/** @} */
529/** @} */
530/** @} */
Definition bslma_allocator.h:545
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.
friend bool operator==(const TimingRequest &lhs, const TimingRequest &rhs)
Definition s_baltst_timingrequest.h:324
int makeSelection(const char *name, int nameLength)
bool isUndefinedValue() const
Definition s_baltst_timingrequest.h:507
bsls::ObjectBuffer< s_baltst::Sqrt > d_sqrt
Definition s_baltst_timingrequest.h:84
static const char CLASS_NAME[]
Definition s_baltst_timingrequest.h:116
static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[]
Definition s_baltst_timingrequest.h:118
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:428
s_baltst::Sqrt & makeSqrt()
bool isSqrtValue() const
Definition s_baltst_timingrequest.h:489
int accessSelection(t_ACCESSOR &accessor) const
Definition s_baltst_timingrequest.h:449
int selectionId() const
Definition s_baltst_timingrequest.h:443
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)
int manipulateSelection(t_MANIPULATOR &manipulator)
Definition s_baltst_timingrequest.h:402
s_baltst::BigRecord & makeBig(const s_baltst::BigRecord &value)
TimingRequest(const TimingRequest &original, bslma::Allocator *basicAllocator=0)
TimingRequest(bslma::Allocator *basicAllocator=0)
Definition s_baltst_timingrequest.h:388
s_baltst::BasicRecord & makeBasic()
friend bool operator!=(const TimingRequest &lhs, const TimingRequest &rhs)
Definition s_baltst_timingrequest.h:332
s_baltst::BigRecord & makeBig()
@ SELECTION_ID_UNDEFINED
Definition s_baltst_timingrequest.h:99
@ SELECTION_ID_BASIC
Definition s_baltst_timingrequest.h:101
@ SELECTION_ID_SQRT
Definition s_baltst_timingrequest.h:100
@ SELECTION_ID_BIG
Definition s_baltst_timingrequest.h:102
friend bsl::ostream & operator<<(bsl::ostream &stream, const TimingRequest &rhs)
Definition s_baltst_timingrequest.h:339
bool isBasicValue() const
Definition s_baltst_timingrequest.h:495
static const bdlat_SelectionInfo * lookupSelectionInfo(int id)
s_baltst::Sqrt & sqrt()
Definition s_baltst_timingrequest.h:421
@ SELECTION_INDEX_BASIC
Definition s_baltst_timingrequest.h:111
@ SELECTION_INDEX_SQRT
Definition s_baltst_timingrequest.h:110
@ SELECTION_INDEX_BIG
Definition s_baltst_timingrequest.h:112
bool isBigValue() const
Definition s_baltst_timingrequest.h:501
s_baltst::BigRecord & big()
Definition s_baltst_timingrequest.h:435
@ NUM_SELECTIONS
Definition s_baltst_timingrequest.h:106
int makeSelection(int selectionId)
~TimingRequest()
Destroy this object.
Definition s_baltst_timingrequest.h:395
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:268
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_IDENT_RCSID(tag, str)
BSLS_IDENT_RCSID() - insert ident str (specific to platform/compiler)
Definition bsls_ident.h:244
#define BSLS_IDENT_PRAGMA_ONCE
BSLS_IDENT_PRAGMA_ONCE - macro to avoid multiple inclusion
Definition bsls_ident.h:263
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
Definition baljsn_encoder_testtypes.h:76
Definition s_baltst_address.h:66
Definition bdlat_selectioninfo.h:138
TYPE & object()
Definition bsls_objectbuffer.h:352