diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2018-03-16 11:50:13 -0400 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2018-03-16 14:02:48 -0400 |
commit | f092c84d7fbba8220c8fecca51d0a582e90ee4a7 (patch) | |
tree | 97a5f3e85d80e62c46186f1ebe62b7d106e44fa3 /src/mongo/db/commands.cpp | |
parent | 2b4643d98e5a49af2b57f37a37ce42904bb01af1 (diff) | |
download | mongo-f092c84d7fbba8220c8fecca51d0a582e90ee4a7.tar.gz |
SERVER-33881 move members from Command to BasicCommand
BasicCommand::InvocationShim->BasicCommand::Invocation
Diffstat (limited to 'src/mongo/db/commands.cpp')
-rw-r--r-- | src/mongo/db/commands.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index eaa45a68a41..28cb6ec3c62 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -376,9 +376,9 @@ CommandInvocation::~CommandInvocation() = default; ////////////////////////////////////////////////////////////// // Command -class Command::InvocationShim final : public CommandInvocation { +class BasicCommand::Invocation final : public CommandInvocation { public: - InvocationShim(OperationContext*, const OpMsgRequest& request, Command* command) + Invocation(OperationContext*, const OpMsgRequest& request, BasicCommand* command) : CommandInvocation(command), _command(command), _request(&request), @@ -388,7 +388,7 @@ private: void run(OperationContext* opCtx, CommandReplyBuilder* result) override { try { BSONObjBuilder bob = result->getBodyBuilder(); - bool ok = _command->enhancedRun(opCtx, *_request, bob); + bool ok = _command->run(opCtx, _dbName, _request->body, bob); CommandHelpers::appendCommandStatus(bob, ok); } catch (const ExceptionFor<ErrorCodes::Unauthorized>&) { CommandAuditHook hook(_command); @@ -432,16 +432,17 @@ private: return _request->body; } - Command* const _command; + BasicCommand* const _command; const OpMsgRequest* const _request; const std::string _dbName; }; Command::~Command() = default; -std::unique_ptr<CommandInvocation> Command::parse(OperationContext* opCtx, - const OpMsgRequest& request) { - return stdx::make_unique<InvocationShim>(opCtx, request, this); +std::unique_ptr<CommandInvocation> BasicCommand::parse(OperationContext* opCtx, + const OpMsgRequest& request) { + CommandHelpers::uassertNoDocumentSequences(getName(), request); + return stdx::make_unique<Invocation>(opCtx, request, this); } std::string Command::parseNs(const std::string& dbname, const BSONObj& cmdObj) const { @@ -468,10 +469,10 @@ Command::Command(StringData name, StringData oldName) globalCommandRegistry()->registerCommand(this, name, oldName); } -Status Command::explain(OperationContext* opCtx, - const OpMsgRequest& request, - ExplainOptions::Verbosity verbosity, - BSONObjBuilder* out) const { +Status BasicCommand::explain(OperationContext* opCtx, + const OpMsgRequest& request, + ExplainOptions::Verbosity verbosity, + BSONObjBuilder* out) const { return {ErrorCodes::IllegalOperation, str::stream() << "Cannot explain cmd: " << getName()}; } @@ -551,13 +552,6 @@ void Command::generateHelpResponse(OperationContext* opCtx, replyBuilder->setMetadata(rpc::makeEmptyMetadata()); } -bool BasicCommand::enhancedRun(OperationContext* opCtx, - const OpMsgRequest& request, - BSONObjBuilder& result) { - CommandHelpers::uassertNoDocumentSequences(getName(), request); - return run(opCtx, request.getDatabase().toString(), request.body, result); -} - bool ErrmsgCommandDeprecated::run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, |