Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/command.h
// Copyright (c) 2018-2019 The Bitcoin developers | // Copyright (c) 2018-2019 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_RPC_COMMAND_H | #ifndef BITCOIN_RPC_COMMAND_H | ||||
#define BITCOIN_RPC_COMMAND_H | #define BITCOIN_RPC_COMMAND_H | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <boost/noncopyable.hpp> | |||||
#include <string> | #include <string> | ||||
class JSONRPCRequest; | class JSONRPCRequest; | ||||
/** | /** | ||||
* Base class for all RPC commands. RPCCommand should only | * Base class for all RPC commands. RPCCommand should only | ||||
* be inherited from directly if access to the entire request context is | * be inherited from directly if access to the entire request context is | ||||
* necessary. For more typical cases where only request arguments are | * necessary. For more typical cases where only request arguments are | ||||
* required, see the RPCCommandWithArgsContext class. | * required, see the RPCCommandWithArgsContext class. | ||||
*/ | */ | ||||
class RPCCommand : public boost::noncopyable { | class RPCCommand { | ||||
private: | private: | ||||
const std::string name; | const std::string name; | ||||
/* | /* | ||||
* Child classes should define dependencies as private members. | * Child classes should define dependencies as private members. | ||||
* These dependencies must not be changed, or successive calls to the same | * These dependencies must not be changed, or successive calls to the same | ||||
* command will give unexpected behavior. | * command will give unexpected behavior. | ||||
*/ | */ | ||||
// TODO: Parameter definitions (these will be used to generate help | // TODO: Parameter definitions (these will be used to generate help | ||||
// messages as well) | // messages as well) | ||||
public: | public: | ||||
RPCCommand(const std::string &nameIn) : name(nameIn) {} | RPCCommand(const std::string &nameIn) : name(nameIn) {} | ||||
virtual ~RPCCommand() {} | virtual ~RPCCommand() {} | ||||
RPCCommand(const RPCCommand &) = delete; | |||||
RPCCommand &operator=(const RPCCommand &) = delete; | |||||
/** | /** | ||||
* It is recommended to override Execute(JSONRPCRequest) only if the entire | * It is recommended to override Execute(JSONRPCRequest) only if the entire | ||||
* request context is required. Otherwise, use RPCCommandWithArgsContext | * request context is required. Otherwise, use RPCCommandWithArgsContext | ||||
* instead. | * instead. | ||||
*/ | */ | ||||
virtual UniValue Execute(const JSONRPCRequest &request) const = 0; | virtual UniValue Execute(const JSONRPCRequest &request) const = 0; | ||||
const std::string &GetName() const { return name; }; | const std::string &GetName() const { return name; }; | ||||
Show All 16 Lines |