LBIBCell
 All Classes Functions Variables Friends Pages
ProgressBar.hpp
1 /* Copyright (c) 2013 David Sichau <mail"at"sichau"dot"eu>
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18  * THE SOFTWARE.
19  *
20  */
21 
22 #ifndef UTILIB_PROGRESSBAR_HPP_
23 #define UTILIB_PROGRESSBAR_HPP_
24 
25 #include <UtilLib/include/Timer.hpp>
26 #include <iostream>
27 
28 namespace UtilLib {
36 class ProgressBar {
37  public:
44  explicit ProgressBar(
45  unsigned int expected_count,
46  double updateInterval = 30,
47  std::ostream& os = std::cout);
54  unsigned int operator+=(unsigned int increment);
55 
60  unsigned int operator++();
61 
67  unsigned int operator++(int i);
68 
69  private:
70  unsigned int count_;
71  unsigned int expectedCount_;
72  unsigned int nextTicCount_;
73  unsigned int updateCount_;
74  unsigned int tic_;
75 
78  std::ostream& outputStream_;
82  const float updateInterval_;
83 
84 
90  void displayTic();
91 
95  void displayPercentage();
96 
100  Timer wholeTime_;
101 };
102 } /* end namespace */
103 #endif /* UTILIB_PROGRESSBAR_HPP_ */
a class for timing
Definition: Timer.hpp:32
unsigned int operator+=(unsigned int increment)
Definition: ProgressBar.cpp:47
a class for reporting the current simulation status. Usage: construct an object of this class with th...
Definition: ProgressBar.hpp:36
ProgressBar(unsigned int expected_count, double updateInterval=30, std::ostream &os=std::cout)
Definition: ProgressBar.cpp:27
unsigned int operator++()
Prefix operator.
Definition: ProgressBar.cpp:58