You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LibNfcOperation.hxx 899B

123456789101112131415161718192021222324252627282930
  1. //
  2. // Created by robin on 10/1/17.
  3. //
  4. #ifndef MIFARE_TOOLS_LIBNFCOPERATION_HXX
  5. #define MIFARE_TOOLS_LIBNFCOPERATION_HXX
  6. #include "LibNfcOperation.h"
  7. template<typename T>
  8. void LibNfcOperation::runOperation(QSharedPointer<LibNfcBusiness> libNfc,
  9. std::function<Result<T>(QSharedPointer<LibNfcBusiness>)> operation,
  10. std::function<void(Result<T>)> callback)
  11. {
  12. Result<T>* result = new Result<T>();
  13. auto nfcOperation = new LibNfcOperation(libNfc, [result, operation](QSharedPointer<LibNfcBusiness> libNfc)
  14. {
  15. auto res = operation(libNfc);
  16. *result = res;
  17. });
  18. connect(nfcOperation, &LibNfcOperation::finished, [result, nfcOperation, callback]()
  19. {
  20. nfcOperation->deleteLater();
  21. callback(*result);
  22. delete result;
  23. });
  24. nfcOperation->start();
  25. }
  26. #endif //MIFARE_TOOLS_LIBNFCOPERATION_HXX