Overte C++ Documentation
BakeAssetTask.h
1 //
2 // BakeAssetTask.h
3 // assignment-client/src/assets
4 //
5 // Created by Stephen Birarda on 9/18/17.
6 // Copyright 2017 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_BakeAssetTask_h
13 #define hifi_BakeAssetTask_h
14 
15 #include <memory>
16 
17 #include <QtCore/QDebug>
18 #include <QtCore/QObject>
19 #include <QtCore/QRunnable>
20 #include <QDir>
21 #include <QProcess>
22 
23 #include <AssetUtils.h>
24 
25 class BakeAssetTask : public QObject, public QRunnable {
26  Q_OBJECT
27 public:
28  BakeAssetTask(const AssetUtils::AssetHash& assetHash, const AssetUtils::AssetPath& assetPath, const QString& filePath);
29 
30  // Thread-safe inspection methods
31  bool isBaking() { return _isBaking.load(); }
32  bool wasAborted() const { return _wasAborted.load(); }
33 
34  void run() override;
35 
36 public slots:
37  void abort();
38 
39 signals:
40  void bakeComplete(QString assetHash, QString assetPath, QString tempOutputDir);
41  void bakeFailed(QString assetHash, QString assetPath, QString errors);
42  void bakeAborted(QString assetHash, QString assetPath);
43 
44 private:
45  std::atomic<bool> _isBaking { false };
46  AssetUtils::AssetHash _assetHash;
47  AssetUtils::AssetPath _assetPath;
48  QString _filePath;
49  std::unique_ptr<QProcess> _ovenProcess { nullptr };
50  std::atomic<bool> _wasAborted { false };
51 };
52 
53 #endif // hifi_BakeAssetTask_h