Skip to content

Commit

Permalink
Refactor[BMQT]: turn copy operator for Subscription explicit
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
  • Loading branch information
678098 committed Jul 23, 2024
1 parent 9714d1c commit 8845d1b
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/groups/bmq/bmqt/bmqt_subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,19 @@ class Subscription {

/// Create a new Subscription by copying values from the specified
/// `other`.
Subscription(const Subscription& other);
explicit Subscription(const Subscription& other);

// MANIPULATORS
/// Assign to this object the value of the specified `rhs` object.
Subscription& operator=(const Subscription& rhs);

#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \
defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
/// Assign to this object the value of the specified `rhs` object.
/// After performing this action, the `rhs` object will be left in a
/// valid, but unspecified state.
Subscription& operator=(Subscription&& rhs);
#endif

/// Set the maxUnconfirmedMessages to the specified `value`. The
/// behavior is undefined unless `value >= 0`. If the specified `value`
Expand Down Expand Up @@ -276,9 +286,9 @@ bsl::ostream& operator<<(bsl::ostream& stream, const Subscription& rhs);
// INLINE DEFINITIONS
// ============================================================================

// ----------------------
// -------------------------
// class Subscription_Handle
// ----------------------
// -------------------------

inline SubscriptionHandle::SubscriptionHandle()
: d_id(k_INVALID_HANDLE_ID)
Expand Down Expand Up @@ -385,9 +395,9 @@ inline bsl::ostream& SubscriptionExpression::print(bsl::ostream& stream,
return stream;
}

// ----------------------
// ------------------
// class Subscription
// ----------------------
// ------------------

inline Subscription::Subscription()
: d_maxUnconfirmedMessages()
Expand Down Expand Up @@ -428,6 +438,27 @@ Subscription::print(bsl::ostream& stream, int level, int spacesPerLevel) const
}

// MANIPULATORS
inline Subscription& Subscription::operator=(const Subscription& rhs)
{
d_maxUnconfirmedMessages = rhs.d_maxUnconfirmedMessages;
d_maxUnconfirmedBytes = rhs.d_maxUnconfirmedBytes;
d_consumerPriority = rhs.d_consumerPriority;
d_expression = rhs.d_expression;
return *this;
}

#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \
defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
inline Subscription& Subscription::operator=(Subscription&& rhs)
{
d_maxUnconfirmedMessages = bsl::move(rhs.d_maxUnconfirmedMessages);
d_maxUnconfirmedBytes = bsl::move(rhs.d_maxUnconfirmedBytes);
d_consumerPriority = bsl::move(rhs.d_consumerPriority);
d_expression = bsl::move(rhs.d_expression);
return *this;
}
#endif

inline Subscription& Subscription::setMaxUnconfirmedMessages(int value)
{
d_maxUnconfirmedMessages.emplace(value);
Expand Down

0 comments on commit 8845d1b

Please sign in to comment.