File indexing completed on 2024-04-28 16:53:07
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Ivan Cukic <ivan.cukic(at)kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef ASYNQT_PRIVATE_UTILS_P_H 0008 #define ASYNQT_PRIVATE_UTILS_P_H 0009 0010 #include <QFuture> 0011 #include <QFutureWatcher> 0012 #include <memory> 0013 0014 namespace AsynQt 0015 { 0016 namespace detail 0017 { 0018 #define IMPLEMENT_FUTURE_WATCHER_HANDLER(SignalName, EventName) \ 0019 template<typename T, typename Function> \ 0020 inline void EventName(const std::unique_ptr<QFutureWatcher<T>> &watcher, Function function) \ 0021 { \ 0022 QObject::connect(watcher.get(), &QFutureWatcherBase::SignalName, watcher.get(), function, Qt::QueuedConnection); \ 0023 } \ 0024 \ 0025 template<typename T, typename Function> \ 0026 inline void EventName(const QFutureWatcher<T> &watcher, Function function) \ 0027 { \ 0028 QObject::connect(&watcher, &QFutureWatcherBase::SignalName, &watcher, function, Qt::QueuedConnection); \ 0029 } 0030 0031 IMPLEMENT_FUTURE_WATCHER_HANDLER(finished, onFinished) 0032 IMPLEMENT_FUTURE_WATCHER_HANDLER(canceled, onCanceled) 0033 IMPLEMENT_FUTURE_WATCHER_HANDLER(resultReadyAt, onResultReadyAt) 0034 0035 template<typename Function> 0036 inline void onResultReadyAt(const std::unique_ptr<QFutureWatcher<void>> &watcher, Function function) 0037 { 0038 Q_UNUSED(watcher) 0039 Q_UNUSED(function) 0040 } 0041 0042 #undef IMPLEMENT_FUTURE_WATCHER_HANDLER 0043 0044 } // namespace detail 0045 } // namespace AsynQt 0046 0047 #endif // ASYNQT_PRIVATE_UTILS_P_H