Lightmetrica  0.0.1.50dbee3 (yosakoi)
 All Classes Functions Variables Typedefs Enumerations Enumerator
progressbar.h
1 /*
2  Lightmetrica : A research-oriented renderer
3 
4  Copyright (c) 2014 Hisanari Otsu
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 #ifndef LIGHTMETRICA_PROGRESS_BAR_H
22 #define LIGHTMETRICA_PROGRESS_BAR_H
23 
24 #include <lightmetrica/common.h>
25 #include <string>
26 #include <mutex>
27 #include <atomic>
28 #include <condition_variable>
29 
30 LM_NAMESPACE_BEGIN
31 
37 {
38 public:
39 
40  ProgressBar() {}
41 
42 private:
43 
44  LM_DISABLE_COPY_AND_MOVE(ProgressBar);
45 
46 public:
47 
48  void SetConsoleWidth(int consoleWidth);
49  void Begin(const std::string& taskName);
50  void End();
51  void Abort();
52  void OnReportProgress(double progress, bool done);
53  void RequestUpdateProgress();
54  void ProcessProgressOutput();
55 
56 private:
57 
58  std::atomic<bool> enableProgressBar;
59  std::atomic<bool> requiresProgressUpdate;
60  bool progressPrintDone;
61  bool progressDone;
62  double progress;
63  std::mutex progressMutex;
64  std::string progressTaskName;
65  std::condition_variable progressDoneCond;
66  void* consoleHandle;
67  int consoleWidth;
68 
69 };
70 
71 LM_NAMESPACE_END
72 
73 #endif // LIGHTMETRICA_PROGRESS_BAR_H
Definition: progressbar.h:36