/* Copyright (C) 2018 * swift project Community / Contributors * * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, * or distributed except according to the terms contained in the LICENSE file. */ #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