123456789101112131415161718192021222324252627282930 |
- //
- // Created by robin on 10/1/17.
- //
-
- #ifndef MIFARE_TOOLS_LIBNFCOPERATION_HXX
- #define MIFARE_TOOLS_LIBNFCOPERATION_HXX
-
- #include "LibNfcOperation.h"
-
- template<typename T>
- void LibNfcOperation::runOperation(QSharedPointer<LibNfc::Core::LibNfcContext> libNfc,
- std::function<LibNfc::Utils::Result<T>(QSharedPointer<LibNfc::Core::LibNfcContext>)> operation,
- std::function<void(LibNfc::Utils::Result<T>)> callback)
- {
- LibNfc::Utils::Result<T>* result = nullptr;
- auto nfcOperation = new LibNfcOperation(libNfc, [&result, operation](QSharedPointer<LibNfc::Core::LibNfcContext> libNfc)
- {
- auto res = operation(libNfc);
- result = new LibNfc::Utils::Result<T>(res);
- });
- connect(nfcOperation, &LibNfcOperation::finished, [&result, nfcOperation, callback]()
- {
- nfcOperation->deleteLater();
- callback(*result);
- delete result;
- });
- nfcOperation->start();
- }
-
- #endif //MIFARE_TOOLS_LIBNFCOPERATION_HXX
|