Overte C++ Documentation
baking/src/Baker.h
1 //
2 // Baker.h
3 // tools/oven/src
4 //
5 // Created by Stephen Birarda on 4/14/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_Baker_h
13 #define hifi_Baker_h
14 
15 #include <QtCore/QObject>
16 
17 class Baker : public QObject {
18  Q_OBJECT
19 
20 public:
21  virtual ~Baker() = default;
22 
23  bool shouldStop();
24 
25  bool hasErrors() const { return !_errorList.isEmpty(); }
26  QStringList getErrors() const { return _errorList; }
27 
28  bool hasWarnings() const { return !_warningList.isEmpty(); }
29  QStringList getWarnings() const { return _warningList; }
30 
31  std::vector<QString> getOutputFiles() const { return _outputFiles; }
32 
33  virtual void setIsFinished(bool isFinished);
34  bool isFinished() const { return _isFinished.load(); }
35 
36  virtual void setWasAborted(bool wasAborted);
37 
38  bool wasAborted() const { return _wasAborted.load(); }
39 
40 public slots:
41  virtual void bake() = 0;
42  virtual void abort() { _shouldAbort.store(true); }
43 
44 signals:
45  void finished();
46  void aborted();
47 
48 protected:
49  void handleError(const QString& error);
50  void handleWarning(const QString& warning);
51 
52  void handleErrors(const QStringList& errors);
53 
54  // List of baked output files. For instance, for an FBX this would
55  // include the .fbx, a .fst pointing to the fbx, and all of the fbx texture files.
56  std::vector<QString> _outputFiles;
57 
58  QStringList _errorList;
59  QStringList _warningList;
60 
61  std::atomic<bool> _isFinished { false };
62 
63  std::atomic<bool> _shouldAbort { false };
64  std::atomic<bool> _wasAborted { false };
65 };
66 
67 #endif // hifi_Baker_h