forked from jancarlsson/snarkfront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericProgressBar.cpp
57 lines (44 loc) · 1.02 KB
/
GenericProgressBar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <cassert>
#include <iostream>
#include "GenericProgressBar.hpp"
using namespace std;
namespace snarkfront {
////////////////////////////////////////////////////////////////////////////////
// generic progress bar
//
GenericProgressBar::GenericProgressBar(ostream& os)
: m_os(os),
m_width(0)
{}
GenericProgressBar::GenericProgressBar(ostream& os,
const size_t width)
: m_os(os),
m_width(width)
{
#ifdef USE_ASSERT
assert(2 <= width);
#endif
}
void GenericProgressBar::majorSteps(const size_t numberSteps) {
m_major = numberSteps;
}
void GenericProgressBar::major(const bool newLine) {
if (newLine) m_os << endl;
if (0 == m_width) {
m_os << ".";
} else {
m_os << "(" << m_major << ") ";
}
--m_major;
m_minor = 0;
}
size_t GenericProgressBar::minorSteps() {
return m_width - m_minor;
}
void GenericProgressBar::minor() {
if (0 != m_width) {
m_os << ".";
++m_minor;
}
}
} // namespace snarkfront