LCOV - code coverage report
Current view: top level - src/common - interfaces.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 13 0.0 %
Date: 2023-11-10 23:46:46 Functions: 0 15 0.0 %
Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2021-2022 The Bitcoin Core developers
       2                 :            : // Distributed under the MIT software license, see the accompanying
       3                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :            : 
       5                 :            : #include <interfaces/echo.h>
       6                 :            : #include <interfaces/handler.h>
       7                 :            : 
       8                 :            : #include <boost/signals2/connection.hpp>
       9                 :            : #include <memory>
      10                 :            : #include <utility>
      11                 :            : 
      12                 :            : namespace common {
      13                 :            : namespace {
      14                 :            : class CleanupHandler : public interfaces::Handler
      15                 :            : {
      16                 :            : public:
      17                 :          0 :     explicit CleanupHandler(std::function<void()> cleanup) : m_cleanup(std::move(cleanup)) {}
      18 [ #  # ][ #  # ]:          0 :     ~CleanupHandler() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
                 [ #  # ]
      19         [ #  # ]:          0 :     void disconnect() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
      20                 :            :     std::function<void()> m_cleanup;
      21                 :            : };
      22                 :            : 
      23                 :          0 : class SignalHandler : public interfaces::Handler
      24                 :            : {
      25                 :            : public:
      26         [ #  # ]:          0 :     explicit SignalHandler(boost::signals2::connection connection) : m_connection(std::move(connection)) {}
      27                 :            : 
      28                 :          0 :     void disconnect() override { m_connection.disconnect(); }
      29                 :            : 
      30                 :            :     boost::signals2::scoped_connection m_connection;
      31                 :            : };
      32                 :            : 
      33                 :          0 : class EchoImpl : public interfaces::Echo
      34                 :            : {
      35                 :            : public:
      36                 :          0 :     std::string echo(const std::string& echo) override { return echo; }
      37                 :            : };
      38                 :            : } // namespace
      39                 :            : } // namespace common
      40                 :            : 
      41                 :            : namespace interfaces {
      42                 :          0 : std::unique_ptr<Handler> MakeCleanupHandler(std::function<void()> cleanup)
      43                 :            : {
      44                 :          0 :     return std::make_unique<common::CleanupHandler>(std::move(cleanup));
      45                 :            : }
      46                 :            : 
      47                 :          0 : std::unique_ptr<Handler> MakeSignalHandler(boost::signals2::connection connection)
      48                 :            : {
      49                 :          0 :     return std::make_unique<common::SignalHandler>(std::move(connection));
      50                 :            : }
      51                 :            : 
      52                 :          0 : std::unique_ptr<Echo> MakeEcho() { return std::make_unique<common::EchoImpl>(); }
      53                 :            : } // namespace interfaces

Generated by: LCOV version 1.14