Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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