LCOV - code coverage report
Current view: top level - src/interfaces - handler.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 10 11 90.9 %
Date: 2022-04-21 14:51:19 Functions: 6 7 85.7 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 1 4 25.0 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2018-2021 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/handler.h>
#       6                 :            : 
#       7                 :            : 
#       8                 :            : #include <boost/signals2/connection.hpp>
#       9                 :            : #include <utility>
#      10                 :            : 
#      11                 :            : namespace interfaces {
#      12                 :            : namespace {
#      13                 :            : 
#      14                 :            : class HandlerImpl : public Handler
#      15                 :            : {
#      16                 :            : public:
#      17                 :         41 :     explicit HandlerImpl(boost::signals2::connection connection) : m_connection(std::move(connection)) {}
#      18                 :            : 
#      19                 :         43 :     void disconnect() override { m_connection.disconnect(); }
#      20                 :            : 
#      21                 :            :     boost::signals2::scoped_connection m_connection;
#      22                 :            : };
#      23                 :            : 
#      24                 :            : class CleanupHandler : public Handler
#      25                 :            : {
#      26                 :            : public:
#      27                 :          2 :     explicit CleanupHandler(std::function<void()> cleanup) : m_cleanup(std::move(cleanup)) {}
#      28         [ -  + ]:          2 :     ~CleanupHandler() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
#      29         [ #  # ]:          0 :     void disconnect() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
#      30                 :            :     std::function<void()> m_cleanup;
#      31                 :            : };
#      32                 :            : 
#      33                 :            : } // namespace
#      34                 :            : 
#      35                 :            : std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
#      36                 :         41 : {
#      37                 :         41 :     return std::make_unique<HandlerImpl>(std::move(connection));
#      38                 :         41 : }
#      39                 :            : 
#      40                 :            : std::unique_ptr<Handler> MakeHandler(std::function<void()> cleanup)
#      41                 :          2 : {
#      42                 :          2 :     return std::make_unique<CleanupHandler>(std::move(cleanup));
#      43                 :          2 : }
#      44                 :            : 
#      45                 :            : } // namespace interfaces

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a