// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 #ifndef BLACKSIM_XSWIFTBUS_DBUSASYNCCALLBACKS_H #define BLACKSIM_XSWIFTBUS_DBUSASYNCCALLBACKS_H #include #include namespace XSwiftBus { //! \cond PRIVATE template class DBusAsyncCallbacks { public: DBusAsyncCallbacks() = default; DBusAsyncCallbacks(const std::function &add, const std::function &remove, const std::function &toggled) : m_addHandler(add), m_removeHandler(remove), m_toggledHandler(toggled) {} static dbus_bool_t add(T *watch, void *refcon) { return static_cast(refcon)->m_addHandler(watch); } static void remove(T *watch, void *refcon) { return static_cast(refcon)->m_removeHandler(watch); } static void toggled(T *watch, void *refcon) { return static_cast(refcon)->m_toggledHandler(watch); } private: std::function m_addHandler; std::function m_removeHandler; std::function m_toggledHandler; }; //! \endcond } #endif // guard