17 #ifndef INCLUDED_BMQT_SUBSCRIPTION
18 #define INCLUDED_BMQT_SUBSCRIPTION
34 #include <bsl_optional.h>
35 #include <bsl_ostream.h>
36 #include <bsl_string.h>
37 #include <bslim_printer.h>
38 #include <bslma_allocator.h>
39 #include <bsls_types.h>
48 class MessageIterator;
78 static unsigned int nextId();
93 unsigned int id()
const;
105 print(bsl::ostream& stream,
int level = 0,
int spacesPerLevel = 4)
const;
115 template <
class HASH_ALGORITHM>
116 friend void hashAppend(HASH_ALGORITHM& hashAlgo,
138 bsl::string d_expression;
149 const bsl::string&
text()
const;
165 print(bsl::ostream& stream,
int level = 0,
int spacesPerLevel = 4)
const;
188 bsl::optional<int> d_maxUnconfirmedMessages;
192 bsl::optional<int> d_maxUnconfirmedBytes;
195 bsl::optional<int> d_consumerPriority;
260 print(bsl::ostream& stream,
int level = 0,
int spacesPerLevel = 4)
const;
278 inline SubscriptionHandle::SubscriptionHandle()
279 : d_id(k_INVALID_HANDLE_ID)
285 inline SubscriptionHandle::SubscriptionHandle(
unsigned int id,
288 , d_correlationId(cid)
295 , d_correlationId(cid)
303 return d_correlationId;
313 int spacesPerLevel)
const
319 bslim::Printer printer(&stream, level, spacesPerLevel);
322 printer.printAttribute(
"id", d_id);
323 printer.printAttribute(
"CorrelationId", d_correlationId);
340 const bsl::string& expression,
342 : d_expression(expression)
360 return d_expression.length() == 0 ? d_version ==
e_NONE
366 int spacesPerLevel)
const
372 bslim::Printer printer(&stream, level, spacesPerLevel);
375 printer.printAttribute(
"Expression", d_expression);
376 printer.printAttribute(
"Version", d_version);
388 : d_maxUnconfirmedMessages()
389 , d_maxUnconfirmedBytes()
390 , d_consumerPriority()
403 bslim::Printer printer(&stream, level, spacesPerLevel);
409 d_expression.
print(stream, level, spacesPerLevel);
419 d_maxUnconfirmedMessages.emplace(value);
425 d_maxUnconfirmedBytes.emplace(value);
431 d_consumerPriority.emplace(value);
438 d_expression = value;
445 return d_maxUnconfirmedMessages.value_or(
466 return d_maxUnconfirmedMessages.has_value();
471 return d_maxUnconfirmedBytes.has_value();
476 return d_consumerPriority.has_value();
482 template <
class HASH_ALGORITHM>
492 return lhs.d_id < rhs.d_id;
498 return lhs.d_id == rhs.d_id;
504 return lhs.d_id != rhs.d_id;
510 return rhs.
print(stream, 0, -1);
515 return rhs.
print(stream, 0, -1);
Provide a value-semantic type usable as an efficient identifier.
Definition: bmqa_messageiterator.h:87
Definition: bmqt_correlationid.h:193
Value-semantic type to carry Subscription criteria.
Definition: bmqt_subscription.h:123
const bsl::string & text() const
Definition: bmqt_subscription.h:348
SubscriptionExpression()
Definition: bmqt_subscription.h:332
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition: bmqt_subscription.h:364
Enum
Enum representing criteria format.
Definition: bmqt_subscription.h:128
@ e_NONE
EMPTY.
Definition: bmqt_subscription.h:130
@ e_VERSION_1
Simple Evaluator.
Definition: bmqt_subscription.h:134
Enum version() const
Definition: bmqt_subscription.h:353
bool isValid() const
Definition: bmqt_subscription.h:358
Value-semantic type for unique Subscription id.
Definition: bmqt_subscription.h:59
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition: bmqt_subscription.h:311
friend struct bmqa::MessageImpl
Definition: bmqt_subscription.h:60
const bmqt::CorrelationId & correlationId() const
Definition: bmqt_subscription.h:301
friend bool operator!=(const SubscriptionHandle &lhs, const SubscriptionHandle &rhs)
Definition: bmqt_subscription.h:501
unsigned int id() const
Definition: bmqt_subscription.h:306
friend bool operator<(const SubscriptionHandle &lhs, const SubscriptionHandle &rhs)
Definition: bmqt_subscription.h:489
static const unsigned int k_INVALID_HANDLE_ID
Initial (invalid) value for bmqt::SubscriptionHandle::d_id
Definition: bmqt_subscription.h:65
friend bool operator==(const SubscriptionHandle &lhs, const SubscriptionHandle &rhs)
Definition: bmqt_subscription.h:495
friend void hashAppend(HASH_ALGORITHM &hashAlgo, const SubscriptionHandle &id)
Apply the specified hashAlgo to the specified id.
Definition: bmqt_subscription.h:483
Value-semantic type to carry Subscription parameters.
Definition: bmqt_subscription.h:169
bool hasMaxUnconfirmedBytes() const
Definition: bmqt_subscription.h:469
bool hasMaxUnconfirmedMessages() const
Definition: bmqt_subscription.h:464
Subscription & setConsumerPriority(int value)
Definition: bmqt_subscription.h:429
static const int k_DEFAULT_MAX_UNCONFIRMED_MESSAGES
Definition: bmqt_subscription.h:179
int consumerPriority() const
Get the number for the consumerPriority parameter.
Definition: bmqt_subscription.h:454
static const int k_DEFAULT_CONSUMER_PRIORITY
Definition: bmqt_subscription.h:181
Subscription()
Create a new Subscription.
Definition: bmqt_subscription.h:387
Subscription & setMaxUnconfirmedBytes(int value)
Definition: bmqt_subscription.h:423
static const int k_CONSUMER_PRIORITY_MIN
Constant representing the minimum valid consumer priority.
Definition: bmqt_subscription.h:174
Subscription & setMaxUnconfirmedMessages(int value)
Definition: bmqt_subscription.h:417
static const int k_DEFAULT_MAX_UNCONFIRMED_BYTES
Definition: bmqt_subscription.h:180
const SubscriptionExpression & expression() const
Definition: bmqt_subscription.h:459
int maxUnconfirmedMessages() const
Get the number for the maxUnconfirmedMessages parameter.
Definition: bmqt_subscription.h:443
Subscription & setExpression(const SubscriptionExpression &value)
Definition: bmqt_subscription.h:436
static const int k_CONSUMER_PRIORITY_MAX
Constant representing the maximum valid consumer priority.
Definition: bmqt_subscription.h:177
int maxUnconfirmedBytes() const
Get the number for the maxUnconfirmedBytes parameter.
Definition: bmqt_subscription.h:449
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition: bmqt_subscription.h:397
bool hasConsumerPriority() const
Definition: bmqt_subscription.h:474
void hashAppend(HASH_ALGORITHM &hashAlgo, const SubscriptionHandle &id)
Apply the specified hashAlgo to the specified id.
Definition: bmqt_subscription.h:483
void hashAppend(HASH_ALGORITHM &hashAlgo, const CorrelationId &value)
Definition: bmqt_correlationid.h:504
bsl::ostream & operator<<(bsl::ostream &stream, CompressionAlgorithmType::Enum value)
Definition: bmqt_compressionalgorithmtype.h:141
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: bmqt_correlationid.h:582
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: bmqt_correlationid.h:576
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: bmqt_correlationid.h:588
Definition: bmqa_abstractsession.h:42