Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / benchmark_app / progress_bar.hpp
1 // Copyright (C) 2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <memory>
8
9 #include <samples/console_progress.hpp>
10
11 /// @brief Responsible for progress bar handling within the benchmark_app
12 class ProgressBar {
13 public:
14     ProgressBar(size_t totalNum, bool stream_output) {
15         _bar.reset(new ConsoleProgress(totalNum, stream_output));
16         _isFinished = true;
17     }
18
19     void addProgress(size_t num) {
20         _isFinished = false;
21         _bar->addProgress(num);
22     }
23
24     void finish() {
25         _isFinished = true;
26         _bar->finish();
27         std::cout << std::endl;
28     }
29
30     void newBar(size_t totalNum) {
31         if (_isFinished) {
32             _bar.reset(new ConsoleProgress(totalNum));
33         } else {
34             throw std::logic_error("Can't create new bar. Current progress bar is still in progress");
35         }
36     }
37
38 private:
39     std::unique_ptr<ConsoleProgress> _bar;
40     bool _isFinished;
41 };