Skip to content

Commit

Permalink
Refactor[BMQ,MQB]: remove redundant virtual, s_allocator_p (#538)
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeny Malygin <[email protected]>
  • Loading branch information
678098 authored Dec 5, 2024
1 parent 94d9784 commit 35451ff
Show file tree
Hide file tree
Showing 23 changed files with 816 additions and 883 deletions.
44 changes: 24 additions & 20 deletions src/groups/bmq/bmqa/bmqa_mocksession.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,27 @@
/// ```
/// void unitTest()
/// {
/// bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator();
///
/// // Create an event handler
/// EventHandler eventHandler(d_allocator_p);
/// EventHandler eventHandler(allocator);
///
/// // The following static initializer method calls all the appropriate
/// // static initializers of the underlying components needed for the
/// // 'MockSession'. The constructor of 'MockSession' will call it in
/// // any case but if events need to be built outside the scope of the
/// // creation of 'MockSession' you will need to explicitly invoke this
/// // static initializer method.
/// bmqa::MockSession::initialize(s_allocator_p);
/// bmqa::MockSession::initialize(allocator);
///
/// bslma::ManagedPtr<bmqa::SessionEventHandler> handlerMp;
/// handlerMp.load(&eventHandler, 0, bslma::ManagedPtrUtil::noOpDeleter);
///
/// bmqa::MockSession mockSession(handlerMp,
/// bmqt::SessionOptions(d_allocator_p),
/// d_allocator_p);
/// bmqt::SessionOptions(allocator),
/// allocator);
///
/// bmqa::QueueId queueId(bmqt::CorrelationId(1), d_allocator_p);
/// bmqa::QueueId queueId(bmqt::CorrelationId(1), allocator);
/// bmqt::CorrelationId corrId(1);
///
/// // Expect a call to start and the call emits an 'e_CONNECTED' event.
Expand All @@ -237,7 +239,7 @@
/// bmqt::SessionEventType::e_CONNECTED,
/// 0, // statusCode
/// "", // errorDescription
/// d_allocator_p));
/// allocator));
///
/// // Make a call to startAsync and emit the event that is enqueued from
/// // that call.
Expand Down Expand Up @@ -292,7 +294,7 @@
/// queueId1,
/// bmqt::OpenQueueResult::e_TIMEOUT, // statusCode
/// "Local Timeout", // errorDescription
/// d_allocator_p);
/// allocator);
/// mockSession.enqueueEvent(openQueueResult);
///
/// // We just enqueued a 'bmqa::OpenQueueStatus' to be emitted. We can
Expand Down Expand Up @@ -321,13 +323,13 @@
///
/// // Simply creating a blob buffer factory on the stack to be used by
/// // 'createAckEvent'. Typically you would have one for the component.
/// bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, d_allocator_p);
/// bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, allocator);
///
/// // The method 'createAckEvent' takes a vector of 'AckParams' to
/// // specify multiple acks per event, but here we are only acknowledging
/// // 1 message. Specify a positive ack with 'e_SUCCESS' here but you
/// // can specify any from 'bmqt::AckResult::Enum'.
/// bsl::vector<bmqa::MockSessionUtil::AckParams> acks(d_allocator_p);
/// bsl::vector<bmqa::MockSessionUtil::AckParams> acks(allocator);
/// acks.emplace_back(bmqt::AckResult::e_SUCCESS,
/// bmqt::CorrelationId(1),
/// bmqt::MessageGUID(), // Real GUID needed if you want
Expand All @@ -339,7 +341,7 @@
/// mockSession.enqueueEvent(bmqa::MockSessionUtil::createAckEvent(
/// acks,
/// &bufferFactory,
/// d_allocator_p));
/// allocator));
///
/// // Emit the enqueued ack event.
/// ASSERT_EQ(mockSession.emitEvent(), true);
Expand All @@ -365,7 +367,7 @@
/// bmqt::SessionEventType::e_DISCONNECTED,
/// 0, // statusCode
/// "", // errorDescription
/// d_allocator_p));
/// allocator));
/// ASSERT_EQ(mockSession.emitEvent(), true);
///
/// // Our event handler internally just stores the event emitted, so pop
Expand Down Expand Up @@ -396,17 +398,19 @@
/// ```
/// void unitTest()
/// {
/// bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator();
///
/// // MockSession created without an eventHandler.
/// bmqa::MockSession mockSession(bmqt::SessionOptions(d_allocator_p),
/// d_allocator_p);
/// bmqa::MockSession mockSession(bmqt::SessionOptions(allocator),
/// allocator);
///
/// // The following static initializer method calls all the appropriate
/// // static initializers of the underlying components needed for the
/// // 'MockSession'. The constructor of 'MockSession' will call it in
/// // any case but if events need to be built outside the scope of the
/// // creation of 'MockSession' you will need to explicitly invoke this
/// // static initializer method.
/// // bmqa::MockSession::initialize(s_allocator_p);
/// // bmqa::MockSession::initialize(allocator);
///
/// // Create simple queueIds and corrIds
/// bmqa::QueueId queueId(1);
Expand All @@ -421,7 +425,7 @@
///
/// // Simply creating a blob buffer factory on the stack to be used by
/// // 'createAckEvent'. Typically you would have one for the component.
/// bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, d_allocator_p);
/// bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, allocator);
///
/// // We then expect that 'nextEvent' will be called to return the
/// // 'e_CONNECTED' event from the broker
Expand All @@ -431,7 +435,7 @@
/// bmqt::CorrelationId::autoValue(),
/// 0, // errorCode
/// "", // errorDescription
/// d_allocator_p));
/// allocator));
/// // Note that we use an 'autoValue' for correlationId because it's
/// // irrelevant for a 'CONNECTED' event.
///
Expand All @@ -448,14 +452,14 @@
/// queueId,
/// bmqt::OpenQueueResult::e_SUCCESS, // statusCode
/// "", // errorDescription
/// d_allocator_p);
/// allocator);
/// BMQA_EXPECT_CALL(mockSession, openQueueSync(&queueId, uri, flags))
/// .returning(expectedResult);
///
/// // Build our incoming message event.
/// bsl::vector<bmqa::MockSessionUtil::PushMessageParams> pushMsgs(
/// d_allocator_p);
/// bdlbb::Blob payload(&bufferFactory, d_allocator_p);
/// allocator);
/// bdlbb::Blob payload(&bufferFactory, allocator);
/// bdlbb::BlobUtil::append(&payload, "hello", 6);
///
/// const char guidHex[] = "00000000000000000000000000000001";
Expand All @@ -473,7 +477,7 @@
/// bmqa::Event pushMsgEvent = bmqa::MockSessionUtil::createPushEvent(
/// pushMsgs,
/// &bufferFactory,
/// d_allocator_p);
/// allocator);
/// BMQA_EXPECT_CALL(mockSession, nextEvent(bsls::TimeInterval()))
/// .returning(pushMsgEvent);
///
Expand Down
11 changes: 6 additions & 5 deletions src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@
/// Basic Usage Example
///-------------------
//
// bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator();
//
// SimpleEvaluator evaluator;
// bsl::string expression = "foo < 3 | bar > 4";
//
// CompilationContext compilationContext(s_allocator_p);
// CompilationContext compilationContext(allocator);
//
// if (int rc = evaluator.compile(expression, compilationContext)) {
// bsl::cerr << compilationContext.lastErrorMessage() << "\n";
// // don't use evaluator
// }
//
// MockPropertiesReader reader(s_allocator_p);
// EvaluationContext evaluationContext(&reader,
// bmqtst::TestHelperUtil::allocator()); bool result =
// evaluator.evaluate(evaluationContext);
// MockPropertiesReader reader(allocator);
// EvaluationContext evaluationContext(&reader, allocator);
// bool result = evaluator.evaluate(evaluationContext);
//..

// BDE
Expand Down
2 changes: 1 addition & 1 deletion src/groups/bmq/bmqu/bmqu_operationchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
// 'bmqu::OperationChain'.
//..
// // create a chain
// bmqu::OperationChain chain(s_allocator_p);
// bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator());
//
// static const int k_MY_PAYLOAD = 42;
// static const int k_MY_CLIENT_ID = 42;
Expand Down
25 changes: 13 additions & 12 deletions src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ namespace mqbblp {
// ========================

/// Mechanism to manage queues on a cluster.
class ClusterQueueHelper : public mqbc::ClusterStateObserver,
public mqbc::ClusterMembershipObserver,
public mqbc::ElectorInfoObserver {
class ClusterQueueHelper BSLS_KEYWORD_FINAL
: public mqbc::ClusterStateObserver,
public mqbc::ClusterMembershipObserver,
public mqbc::ElectorInfoObserver {
private:
// CLASS-SCOPE CATEGORY
BALL_LOG_SET_CLASS_CATEGORY("MQBBLP.CLUSTERQUEUEHELPER");
Expand Down Expand Up @@ -954,7 +955,7 @@ class ClusterQueueHelper : public mqbc::ClusterStateObserver,

/// Callback invoked when self node's status changes to the specified
/// `value`.
virtual void onSelfNodeStatus(bmqp_ctrlmsg::NodeStatus::Value value)
void onSelfNodeStatus(bmqp_ctrlmsg::NodeStatus::Value value)
BSLS_KEYWORD_OVERRIDE;

// PRIVATE MANIPULATORS
Expand All @@ -965,8 +966,8 @@ class ClusterQueueHelper : public mqbc::ClusterStateObserver,
/// for the `node`, and it implies that the cluster has transitioned to
/// a state of no leader, and in this case, `status` will be
/// `UNDEFINED`.
virtual void onClusterLeader(mqbnet::ClusterNode* node,
mqbc::ElectorInfoLeaderStatus::Enum status)
void onClusterLeader(mqbnet::ClusterNode* node,
mqbc::ElectorInfoLeaderStatus::Enum status)
BSLS_KEYWORD_OVERRIDE;

// PRIVATE MANIPULATORS
Expand All @@ -977,15 +978,15 @@ class ClusterQueueHelper : public mqbc::ClusterStateObserver,
///
/// THREAD: This method is invoked in the associated cluster's
/// dispatcher thread.
virtual void onQueueAssigned(const mqbc::ClusterStateQueueInfo& info)
void onQueueAssigned(const mqbc::ClusterStateQueueInfo& info)
BSLS_KEYWORD_OVERRIDE;

/// Callback invoked when a queue with the specified `info` gets
/// unassigned from the cluster.
///
/// THREAD: This method is invoked in the associated cluster's
/// dispatcher thread.
virtual void onQueueUnassigned(const mqbc::ClusterStateQueueInfo& info)
void onQueueUnassigned(const mqbc::ClusterStateQueueInfo& info)
BSLS_KEYWORD_OVERRIDE;

/// Callback invoked when a queue with the specified `uri` belonging to
Expand All @@ -995,10 +996,10 @@ class ClusterQueueHelper : public mqbc::ClusterStateObserver,
///
/// THREAD: This method is invoked in the associated cluster's
/// dispatcher thread.
virtual void onQueueUpdated(const bmqt::Uri& uri,
const bsl::string& domain,
const AppInfos& addedAppIds,
const AppInfos& removedAppIds = AppInfos())
void onQueueUpdated(const bmqt::Uri& uri,
const bsl::string& domain,
const AppInfos& addedAppIds,
const AppInfos& removedAppIds = AppInfos())
BSLS_KEYWORD_OVERRIDE;

private:
Expand Down
Loading

0 comments on commit 35451ff

Please sign in to comment.