BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_sqrt.h
Go to the documentation of this file.
1/// @file s_baltst_sqrt.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_sqrt.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_SQRT
9#define INCLUDED_S_BALTST_SQRT
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_sqrt_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_sqrt s_baltst_sqrt
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_sqrt
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_sqrt-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_sqrt-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_sqrt
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 <bsls_assert.h>
54
55#include <bsl_iosfwd.h>
56#include <bsl_limits.h>
57
58
59
60namespace s_baltst { class Sqrt; }
61namespace s_baltst {
62
63 // ==========
64 // class Sqrt
65 // ==========
66
67/// Simulate a square root request/response
68///
69/// See @ref s_baltst_sqrt
70class Sqrt {
71
72 // INSTANCE DATA
73 double d_value;
74
75 public:
76 // TYPES
77 enum {
79 };
80
81 enum {
83 };
84
85 enum {
87 };
88
89 // CONSTANTS
90 static const char CLASS_NAME[];
91
93
94 public:
95 // CLASS METHODS
96
97 /// Return attribute information for the attribute indicated by the
98 /// specified `id` if the attribute exists, and 0 otherwise.
100
101 /// Return attribute information for the attribute indicated by the
102 /// specified `name` of the specified `nameLength` if the attribute
103 /// exists, and 0 otherwise.
105 const char *name,
106 int nameLength);
107
108 // CREATORS
109
110 /// Create an object of type `Sqrt` having the default value.
112
113
114 // MANIPULATORS
115
116 /// Reset this object to the default value (i.e., its value upon
117 /// default construction).
118 void reset();
119
120 /// Invoke the specified `manipulator` sequentially on the address of
121 /// each (modifiable) attribute of this object, supplying `manipulator`
122 /// with the corresponding attribute information structure until such
123 /// invocation returns a non-zero value. Return the value from the
124 /// last invocation of `manipulator` (i.e., the invocation that
125 /// terminated the sequence).
126 template <typename t_MANIPULATOR>
127 int manipulateAttributes(t_MANIPULATOR& manipulator);
128
129 /// Invoke the specified `manipulator` on the address of
130 /// the (modifiable) attribute indicated by the specified `id`,
131 /// supplying `manipulator` with the corresponding attribute
132 /// information structure. Return the value returned from the
133 /// invocation of `manipulator` if `id` identifies an attribute of this
134 /// class, and -1 otherwise.
135 template <typename t_MANIPULATOR>
136 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
137
138 /// Invoke the specified `manipulator` on the address of
139 /// the (modifiable) attribute indicated by the specified `name` of the
140 /// specified `nameLength`, supplying `manipulator` with the
141 /// corresponding attribute information structure. Return the value
142 /// returned from the invocation of `manipulator` if `name` identifies
143 /// an attribute of this class, and -1 otherwise.
144 template <typename t_MANIPULATOR>
145 int manipulateAttribute(t_MANIPULATOR& manipulator,
146 const char *name,
147 int nameLength);
148
149 /// Return a reference to the modifiable "Value" attribute of this
150 /// object.
151 double& value();
152
153 // ACCESSORS
154
155 /// Format this object to the specified output `stream` at the
156 /// optionally specified indentation `level` and return a reference to
157 /// the modifiable `stream`. If `level` is specified, optionally
158 /// specify `spacesPerLevel`, the number of spaces per indentation level
159 /// for this and all of its nested objects. Each line is indented by
160 /// the absolute value of `level * spacesPerLevel`. If `level` is
161 /// negative, suppress indentation of the first line. If
162 /// `spacesPerLevel` is negative, suppress line breaks and format the
163 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
164 ///
165 /// \note Note that a trailing newline is provided
166 /// in multiline mode only.
167 bsl::ostream& print(bsl::ostream& stream,
168 int level = 0,
169 int spacesPerLevel = 4) const;
170
171 /// Invoke the specified `accessor` sequentially on each
172 /// (non-modifiable) attribute of this object, supplying `accessor`
173 /// with the corresponding attribute information structure until such
174 /// invocation returns a non-zero value. Return the value from the
175 /// last invocation of `accessor` (i.e., the invocation that terminated
176 /// the sequence).
177 template <typename t_ACCESSOR>
178 int accessAttributes(t_ACCESSOR& accessor) const;
179
180 /// Invoke the specified `accessor` on the (non-modifiable) attribute
181 /// of this object indicated by the specified `id`, supplying `accessor`
182 /// with the corresponding attribute information structure. Return the
183 /// value returned from the invocation of `accessor` if `id` identifies
184 /// an attribute of this class, and -1 otherwise.
185 template <typename t_ACCESSOR>
186 int accessAttribute(t_ACCESSOR& accessor, int id) const;
187
188 /// Invoke the specified `accessor` on the (non-modifiable) attribute
189 /// of this object indicated by the specified `name` of the specified
190 /// `nameLength`, supplying `accessor` with the corresponding attribute
191 /// information structure. Return the value returned from the
192 /// invocation of `accessor` if `name` identifies an attribute of this
193 /// class, and -1 otherwise.
194 template <typename t_ACCESSOR>
195 int accessAttribute(t_ACCESSOR& accessor,
196 const char *name,
197 int nameLength) const;
198
199 /// Return the value of the "Value" attribute of this object.
200 double value() const;
201
202 // HIDDEN FRIENDS
203
204 /// Return `true` if the specified `lhs` and `rhs` attribute objects
205 /// have the same value, and `false` otherwise. Two attribute objects
206 /// have the same value if each respective attribute has the same value.
207 friend bool operator==(const Sqrt& lhs, const Sqrt& rhs)
208 {
209 return lhs.value() == rhs.value();
210 }
211
212 /// Returns `!(lhs == rhs)`
213 friend bool operator!=(const Sqrt& lhs, const Sqrt& rhs)
214 {
215 return !(lhs == rhs);
216 }
217
218 /// Format the specified `rhs` to the specified output `stream` and
219 /// return a reference to the modifiable `stream`.
220 friend bsl::ostream& operator<<(bsl::ostream& stream, const Sqrt& rhs)
221 {
222 return rhs.print(stream, 0, -1);
223 }
224};
225
226} // close package namespace
227
228// TRAITS
229
231template <>
233
234// ============================================================================
235// INLINE DEFINITIONS
236// ============================================================================
237
238namespace s_baltst {
239
240 // ----------
241 // class Sqrt
242 // ----------
243
244// CLASS METHODS
245// MANIPULATORS
246template <typename t_MANIPULATOR>
247int Sqrt::manipulateAttributes(t_MANIPULATOR& manipulator)
248{
249 int ret;
250
251 ret = manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
252 if (ret) {
253 return ret;
254 }
255
256 return 0;
257}
258
259template <typename t_MANIPULATOR>
260int Sqrt::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
261{
262 enum { NOT_FOUND = -1 };
263
264 switch (id) {
265 case ATTRIBUTE_ID_VALUE: {
266 return manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
267 }
268 default:
269 return NOT_FOUND;
270 }
271}
272
273template <typename t_MANIPULATOR>
275 t_MANIPULATOR& manipulator,
276 const char *name,
277 int nameLength)
278{
279 enum { NOT_FOUND = -1 };
280
281 const bdlat_AttributeInfo *attributeInfo =
282 lookupAttributeInfo(name, nameLength);
283 if (0 == attributeInfo) {
284 return NOT_FOUND;
285 }
286
287 return manipulateAttribute(manipulator, attributeInfo->d_id);
288}
289
290inline
291double& Sqrt::value()
292{
293 return d_value;
294}
295
296// ACCESSORS
297template <typename t_ACCESSOR>
298int Sqrt::accessAttributes(t_ACCESSOR& accessor) const
299{
300 int ret;
301
302 ret = accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
303 if (ret) {
304 return ret;
305 }
306
307 return 0;
308}
309
310template <typename t_ACCESSOR>
311int Sqrt::accessAttribute(t_ACCESSOR& accessor, int id) const
312{
313 enum { NOT_FOUND = -1 };
314
315 switch (id) {
316 case ATTRIBUTE_ID_VALUE: {
317 return accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
318 }
319 default:
320 return NOT_FOUND;
321 }
322}
323
324template <typename t_ACCESSOR>
326 t_ACCESSOR& accessor,
327 const char *name,
328 int nameLength) const
329{
330 enum { NOT_FOUND = -1 };
331
332 const bdlat_AttributeInfo *attributeInfo =
333 lookupAttributeInfo(name, nameLength);
334 if (0 == attributeInfo) {
335 return NOT_FOUND;
336 }
337
338 return accessAttribute(accessor, attributeInfo->d_id);
339}
340
341inline
342double Sqrt::value() const
343{
344 return d_value;
345}
346
347} // close package namespace
348
349// FREE FUNCTIONS
350
351
352#endif
353
354// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
355// USING bas_codegen.pl s_baltst_sqrt.xsd --mode msg --includedir . --msgComponent sqrt --noRecurse --noExternalization --noHashSupport --noAggregateConversion
356// ----------------------------------------------------------------------------
357// NOTICE:
358// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
359// Property of Bloomberg Finance L.P. (BFLP)
360// This software is made available solely pursuant to the
361// terms of a BFLP license agreement which governs its use.
362// ------------------------------- END-OF-FILE --------------------------------
363
364/** @} */
365/** @} */
366/** @} */
Definition s_baltst_sqrt.h:70
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
@ ATTRIBUTE_INDEX_VALUE
Definition s_baltst_sqrt.h:86
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_sqrt.h:247
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_sqrt.h:298
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_sqrt.h:260
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
Sqrt()
Create an object of type Sqrt having the default value.
friend bool operator==(const Sqrt &lhs, const Sqrt &rhs)
Definition s_baltst_sqrt.h:207
friend bsl::ostream & operator<<(bsl::ostream &stream, const Sqrt &rhs)
Definition s_baltst_sqrt.h:220
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_sqrt.h:311
friend bool operator!=(const Sqrt &lhs, const Sqrt &rhs)
Returns !(lhs == rhs)
Definition s_baltst_sqrt.h:213
@ NUM_ATTRIBUTES
Definition s_baltst_sqrt.h:82
double & value()
Definition s_baltst_sqrt.h:291
static const char CLASS_NAME[]
Definition s_baltst_sqrt.h:90
@ ATTRIBUTE_ID_VALUE
Definition s_baltst_sqrt.h:78
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_sqrt.h:92
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:294
#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
Definition s_baltst_address.h:66
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142
Definition bdlat_typetraits.h:146