diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/echo.cpp | 18 | ||||
-rw-r--r-- | src/interfaces/echo.h | 26 | ||||
-rw-r--r-- | src/interfaces/init.cpp | 2 | ||||
-rw-r--r-- | src/interfaces/init.h | 2 |
4 files changed, 48 insertions, 0 deletions
diff --git a/src/interfaces/echo.cpp b/src/interfaces/echo.cpp new file mode 100644 index 0000000000..9bbb42217b --- /dev/null +++ b/src/interfaces/echo.cpp @@ -0,0 +1,18 @@ +// Copyright (c) 2021 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include <interfaces/echo.h> + +#include <memory> + +namespace interfaces { +namespace { +class EchoImpl : public Echo +{ +public: + std::string echo(const std::string& echo) override { return echo; } +}; +} // namespace +std::unique_ptr<Echo> MakeEcho() { return std::make_unique<EchoImpl>(); } +} // namespace interfaces diff --git a/src/interfaces/echo.h b/src/interfaces/echo.h new file mode 100644 index 0000000000..5578d9d9e6 --- /dev/null +++ b/src/interfaces/echo.h @@ -0,0 +1,26 @@ +// Copyright (c) 2021 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_INTERFACES_ECHO_H +#define BITCOIN_INTERFACES_ECHO_H + +#include <memory> +#include <string> + +namespace interfaces { +//! Simple string echoing interface for testing. +class Echo +{ +public: + virtual ~Echo() {} + + //! Echo provided string. + virtual std::string echo(const std::string& echo) = 0; +}; + +//! Return implementation of Echo interface. +std::unique_ptr<Echo> MakeEcho(); +} // namespace interfaces + +#endif // BITCOIN_INTERFACES_ECHO_H diff --git a/src/interfaces/init.cpp b/src/interfaces/init.cpp index 1eeea9b5cb..a3c949e616 100644 --- a/src/interfaces/init.cpp +++ b/src/interfaces/init.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <interfaces/chain.h> +#include <interfaces/echo.h> #include <interfaces/init.h> #include <interfaces/node.h> #include <interfaces/wallet.h> @@ -11,5 +12,6 @@ namespace interfaces { std::unique_ptr<Node> Init::makeNode() { return {}; } std::unique_ptr<Chain> Init::makeChain() { return {}; } std::unique_ptr<WalletClient> Init::makeWalletClient(Chain& chain) { return {}; } +std::unique_ptr<Echo> Init::makeEcho() { return {}; } Ipc* Init::ipc() { return nullptr; } } // namespace interfaces diff --git a/src/interfaces/init.h b/src/interfaces/init.h index 8aea027f01..2a38054a17 100644 --- a/src/interfaces/init.h +++ b/src/interfaces/init.h @@ -11,6 +11,7 @@ struct NodeContext; namespace interfaces { class Chain; +class Echo; class Ipc; class Node; class WalletClient; @@ -29,6 +30,7 @@ public: virtual std::unique_ptr<Node> makeNode(); virtual std::unique_ptr<Chain> makeChain(); virtual std::unique_ptr<WalletClient> makeWalletClient(Chain& chain); + virtual std::unique_ptr<Echo> makeEcho(); virtual Ipc* ipc(); }; |