libbmq  a5f8a06ba1d16cb5a65643e1fa7f1a1d6aadef40
bmqa_closequeuestatus.h
Go to the documentation of this file.
1 // Copyright 2019-2023 Bloomberg Finance L.P.
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 // bmqa_closequeuestatus.h -*-C++-*-
17 #ifndef INCLUDED_BMQA_CLOSEQUEUESTATUS
18 #define INCLUDED_BMQA_CLOSEQUEUESTATUS
19 
38 
39 // BMQ
40 
41 #include <bmqa_queueid.h>
42 #include <bmqt_resultcode.h>
43 
44 // BDE
45 #include <bsl_iostream.h>
46 #include <bsl_string.h>
47 #include <bslma_allocator.h>
48 #include <bslma_default.h>
49 #include <bslma_usesbslmaallocator.h>
50 #include <bslmf_nestedtraitdeclaration.h>
51 #include <bsls_unspecifiedbool.h>
52 
53 namespace BloombergLP {
54 namespace bmqa {
55 
56 // ======================
57 // class CloseQueueStatus
58 // ======================
59 
63  private:
64  // DATA
65 
67  QueueId d_queueId;
68 
71 
73  bsl::string d_errorDescription;
74 
75  public:
76  // TRAITS
77  BSLMF_NESTED_TRAIT_DECLARATION(CloseQueueStatus, bslma::UsesBslmaAllocator)
78 
79  // TYPES
80 
81  // Use of an `UnspecifiedBool` to prevent implicit conversions to
82  // integral values, and comparisons between different classes which
83  // have boolean operators.
84  typedef bsls::UnspecifiedBool<CloseQueueStatus>::BoolType BoolType;
85 
86  // CREATORS
87 
89  explicit CloseQueueStatus(bslma::Allocator* allocator = 0);
90 
93  CloseQueueStatus(const bmqa::CloseQueueStatus& other,
94  bslma::Allocator* allocator = 0);
95 
100  bmqt::CloseQueueResult::Enum result,
101  const bsl::string& errorDescription,
102  bslma::Allocator* allocator = 0);
103 
104  // MANIPULATORS
105 
108  CloseQueueStatus& operator=(const CloseQueueStatus& rhs);
109 
110  // ACCESSORS
111 
113  operator BoolType() const;
114 
116  const QueueId& queueId() const;
117 
120  bmqt::CloseQueueResult::Enum result() const;
121 
124  const bsl::string& errorDescription() const;
125 
135  bsl::ostream&
136  print(bsl::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
137 };
138 
139 // FREE OPERATORS
140 
144 bool operator==(const CloseQueueStatus& lhs, const CloseQueueStatus& rhs);
145 
149 bool operator!=(const CloseQueueStatus& lhs, const CloseQueueStatus& rhs);
150 
153 bsl::ostream& operator<<(bsl::ostream& stream, const CloseQueueStatus& rhs);
154 
155 // ============================================================================
156 // INLINE DEFINITIONS
157 // ============================================================================
158 
159 // ----------------------
160 // class CloseQueueStatus
161 // ----------------------
162 
163 // CREATORS
164 inline CloseQueueStatus::CloseQueueStatus(bslma::Allocator* allocator)
165 : d_queueId(allocator)
166 , d_result(bmqt::CloseQueueResult::e_SUCCESS)
167 , d_errorDescription(allocator)
168 {
169  // NOTHING
170 }
171 
173  bslma::Allocator* allocator)
174 : d_queueId(other.d_queueId, allocator)
175 , d_result(other.d_result)
176 , d_errorDescription(other.d_errorDescription)
177 {
178  // NOTHING
179 }
180 
183  const bsl::string& errorDescription,
184  bslma::Allocator* allocator)
185 : d_queueId(queueId, allocator)
186 , d_result(result)
187 , d_errorDescription(errorDescription)
188 {
189  // NOTHING
190 }
191 
192 // MANIPULATORS
193 inline CloseQueueStatus&
195 {
196  d_queueId = other.queueId();
197  d_result = other.result();
198  d_errorDescription = other.errorDescription();
199  return *this;
200 }
201 
202 // ACCESSORS
203 inline CloseQueueStatus::operator BoolType() const
204 {
205  return bsls::UnspecifiedBool<CloseQueueStatus>::makeValue(
207 }
208 
209 inline const QueueId& CloseQueueStatus::queueId() const
210 {
211  return d_queueId;
212 }
213 
215 {
216  return d_result;
217 }
218 
219 inline const bsl::string& CloseQueueStatus::errorDescription() const
220 {
221  return d_errorDescription;
222 }
223 
224 } // close package namespace
225 
226 // FREE OPERATORS
227 inline bsl::ostream& bmqa::operator<<(bsl::ostream& stream,
228  const bmqa::CloseQueueStatus& rhs)
229 {
230  return rhs.print(stream, 0, -1);
231 }
232 
234  const bmqa::CloseQueueStatus& rhs)
235 {
236  return lhs.queueId() == rhs.queueId() && lhs.result() == rhs.result() &&
237  lhs.errorDescription() == rhs.errorDescription();
238 }
239 
241  const bmqa::CloseQueueStatus& rhs)
242 {
243  return !(lhs == rhs);
244 }
245 
246 } // close enterprise namespace
247 
248 #endif
Provide a value-semantic efficient identifier for a queue.
Provide enums for various publicly exposed result code.
Definition: bmqa_closequeuestatus.h:62
bsls::UnspecifiedBool< CloseQueueStatus >::BoolType BoolType
Definition: bmqa_closequeuestatus.h:84
bmqt::CloseQueueResult::Enum result() const
Definition: bmqa_closequeuestatus.h:214
const QueueId & queueId() const
Return the queueId associated to this operation result, if any.
Definition: bmqa_closequeuestatus.h:209
CloseQueueStatus(bslma::Allocator *allocator=0)
Default constructor, use the optionally specified allocator.
Definition: bmqa_closequeuestatus.h:164
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
const bsl::string & errorDescription() const
Definition: bmqa_closequeuestatus.h:219
CloseQueueStatus & operator=(const CloseQueueStatus &rhs)
Definition: bmqa_closequeuestatus.h:194
Value-semantic efficient identifier for a queue.
Definition: bmqa_queueid.h:59
bool operator!=(const CloseQueueStatus &lhs, const CloseQueueStatus &rhs)
Definition: bmqa_closequeuestatus.h:240
bool operator==(const CloseQueueStatus &lhs, const CloseQueueStatus &rhs)
Definition: bmqa_closequeuestatus.h:233
bsl::ostream & operator<<(bsl::ostream &stream, const CloseQueueStatus &rhs)
Definition: bmqa_closequeuestatus.h:227
Definition: bmqa_abstractsession.h:42
Enum
Definition: bmqt_resultcode.h:287
@ e_SUCCESS
Definition: bmqt_resultcode.h:289