libbmq  a5f8a06ba1d16cb5a65643e1fa7f1a1d6aadef40
bmqa_openqueuestatus.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_openqueuestatus.h -*-C++-*-
17 #ifndef INCLUDED_BMQA_OPENQUEUESTATUS
18 #define INCLUDED_BMQA_OPENQUEUESTATUS
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 OpenQueueStatus
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(OpenQueueStatus, bslma::UsesBslmaAllocator)
78 
79  // TYPES
80 
81 
84  typedef bsls::UnspecifiedBool<OpenQueueStatus>::BoolType BoolType;
85 
86  // CREATORS
87 
89  explicit OpenQueueStatus(bslma::Allocator* allocator = 0);
90 
93  OpenQueueStatus(const bmqa::OpenQueueStatus& other,
94  bslma::Allocator* allocator = 0);
95 
100  bmqt::OpenQueueResult::Enum result,
101  const bsl::string& errorDescription,
102  bslma::Allocator* allocator = 0);
103 
104  // MANIPULATORS
105 
107  OpenQueueStatus& operator=(const OpenQueueStatus& rhs);
108 
109  // ACCESSORS
110 
112  operator BoolType() const;
113 
115  const QueueId& queueId() const;
116 
119  bmqt::OpenQueueResult::Enum result() const;
120 
123  const bsl::string& errorDescription() const;
124 
134  bsl::ostream&
135  print(bsl::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
136 };
137 
138 // FREE OPERATORS
139 
143 bool operator==(const OpenQueueStatus& lhs, const OpenQueueStatus& rhs);
144 
148 bool operator!=(const OpenQueueStatus& lhs, const OpenQueueStatus& rhs);
149 
152 bsl::ostream& operator<<(bsl::ostream& stream, const OpenQueueStatus& rhs);
153 
154 // ============================================================================
155 // INLINE DEFINITIONS
156 // ============================================================================
157 
158 // ---------------------
159 // class OpenQueueStatus
160 // ---------------------
161 
162 // CREATORS
163 inline OpenQueueStatus::OpenQueueStatus(bslma::Allocator* allocator)
164 : d_queueId(allocator)
165 , d_result(bmqt::OpenQueueResult::e_SUCCESS)
166 , d_errorDescription(allocator)
167 {
168  // NOTHING
169 }
170 
172  bslma::Allocator* allocator)
173 : d_queueId(other.d_queueId, allocator)
174 , d_result(other.d_result)
175 , d_errorDescription(other.d_errorDescription, allocator)
176 {
177  // NOTHING
178 }
179 
182  const bsl::string& errorDescription,
183  bslma::Allocator* allocator)
184 : d_queueId(queueId, allocator)
185 , d_result(result)
186 , d_errorDescription(errorDescription)
187 {
188  // NOTHING
189 }
190 
191 // MANIPULATORS
192 inline OpenQueueStatus&
194 {
195  d_queueId = other.queueId();
196  d_result = other.result();
197  d_errorDescription = other.errorDescription();
198  return *this;
199 }
200 
201 // ACCESSORS
202 inline OpenQueueStatus::operator BoolType() const
203 {
204  return bsls::UnspecifiedBool<OpenQueueStatus>::makeValue(
206 }
207 
208 inline const QueueId& OpenQueueStatus::queueId() const
209 {
210  return d_queueId;
211 }
212 
214 {
215  return d_result;
216 }
217 
218 inline const bsl::string& OpenQueueStatus::errorDescription() const
219 {
220  return d_errorDescription;
221 }
222 
223 } // close package namespace
224 
225 // FREE OPERATORS
226 inline bsl::ostream& bmqa::operator<<(bsl::ostream& stream,
227  const bmqa::OpenQueueStatus& rhs)
228 {
229  return rhs.print(stream, 0, -1);
230 }
231 
233  const bmqa::OpenQueueStatus& rhs)
234 {
235  return lhs.queueId() == rhs.queueId() && lhs.result() == rhs.result() &&
236  lhs.errorDescription() == rhs.errorDescription();
237 }
238 
240  const bmqa::OpenQueueStatus& rhs)
241 {
242  return !(lhs == rhs);
243 }
244 
245 } // close enterprise namespace
246 
247 #endif
Provide a value-semantic efficient identifier for a queue.
Provide enums for various publicly exposed result code.
Definition: bmqa_openqueuestatus.h:62
bsls::UnspecifiedBool< OpenQueueStatus >::BoolType BoolType
Definition: bmqa_openqueuestatus.h:84
bmqt::OpenQueueResult::Enum result() const
Definition: bmqa_openqueuestatus.h:213
const QueueId & queueId() const
Return the queueId associated to this operation result, if any.
Definition: bmqa_openqueuestatus.h:208
OpenQueueStatus & operator=(const OpenQueueStatus &rhs)
Assignment operator from the specified rhs.
Definition: bmqa_openqueuestatus.h:193
OpenQueueStatus(bslma::Allocator *allocator=0)
Default constructor, use the optionally specified allocator.
Definition: bmqa_openqueuestatus.h:163
const bsl::string & errorDescription() const
Definition: bmqa_openqueuestatus.h:218
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
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:137
@ e_SUCCESS
Definition: bmqt_resultcode.h:139