Line data Source code
1 : // Copyright (c) 2018-2020 The Bitcoin Core developers 2 : // Copyright (c) 2020 The PIVX Core developers 3 : // Distributed under the MIT software license, see the accompanying 4 : // file COPYING or https://www.opensource.org/licenses/mit-license.php. 5 : 6 : #ifndef PIVX_INTERFACES_HANDLER_H 7 : #define PIVX_INTERFACES_HANDLER_H 8 : 9 : #include <memory> 10 : 11 : namespace boost { 12 : namespace signals2 { 13 : class connection; 14 : } // namespace signals2 15 : } // namespace boost 16 : 17 : namespace interfaces { 18 : 19 : //! Generic interface for managing an event handler or callback function 20 : //! registered with another interface. Has a single disconnect method to cancel 21 : //! the registration and prevent any future notifications. 22 0 : class Handler 23 : { 24 : public: 25 : virtual ~Handler() {} 26 : 27 : //! Disconnect the handler. 28 : virtual void disconnect() = 0; 29 : }; 30 : 31 : //! Return handler wrapping a boost signal connection. 32 : std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection); 33 : 34 : } // namespace interfaces 35 : 36 : #endif // PIVX_INTERFACES_HANDLER_H