Changeset View
Standalone View
src/rpc/command.h
- This file was added.
// Copyright (c) 2018-2019 The Bitcoin developers | |||||
// Distributed under the MIT software license, see the accompanying | |||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | |||||
#ifndef BITCOIN_RPC_COMMAND_H | |||||
#define BITCOIN_RPC_COMMAND_H | |||||
#include <string> | |||||
#include <univalue.h> | |||||
/** | |||||
* Base class for all RPC commands. | |||||
*/ | |||||
class RPCCommand { | |||||
private: | |||||
/* | |||||
* Dependencies should be stored here for each RPCCommand instance. | |||||
* The references to these dependencies must not be changed, or successive | |||||
* calls to the same command will give unexpected behavior. | |||||
*/ | |||||
deadalnix: I'm not sure what that comment mean or how it's helping me in any way building RPC commands. | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsUpdated the wording. Hopefully it makes more sense now. jasonbcox: Updated the wording. Hopefully it makes more sense now. | |||||
// TODO: Parameter definitions (these will be used to generate help | |||||
// messages as well) | |||||
public: | |||||
virtual UniValue Execute(const UniValue &args) const = 0; | |||||
virtual std::string GetName() const = 0; | |||||
deadalnixUnsubmitted Not Done Inline ActionsI'm fairly confident hooking custom logic on GetName will not be required. deadalnix: I'm fairly confident hooking custom logic on GetName will not be required. | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsThe intent was to have each class implement GetName() like such: std::string GetName() const { return "my-command-name"; } This is a very common pattern used in Java applications. jasonbcox: The intent was to have each class implement GetName() like such:
```
std::string GetName()… | |||||
deadalnixUnsubmitted Not Done Inline ActionsYou are defining a function. Functions DO stuff. You make that function vitrual => you want subclasses to extend the behavior, ie DO different stuff. It's no surprise that this is done with a virtual function in Java, because this is literally the only tool the language provides. Classes with virtual functions. But in that case, even in java, you ave all the signs that the name is likely not in the right place. deadalnix: You are defining a function. Functions DO stuff. You make that function vitrual => you want… | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsMakes sense. Fixed. jasonbcox: Makes sense. Fixed. | |||||
}; | |||||
#endif // BITCOIN_RPC_COMMAND_H |
I'm not sure what that comment mean or how it's helping me in any way building RPC commands.