OpenMEEG
Loading...
Searching...
No Matches
OpenMEEG
include
progressbar.h
Go to the documentation of this file.
1
// Project Name: OpenMEEG (http://openmeeg.github.io)
2
// © INRIA and ENPC under the French open source license CeCILL-B.
3
// See full copyright notice in the file LICENSE.txt
4
// If you make a copy of this file, you must either:
5
// - provide also LICENSE.txt and modify this header to refer to it.
6
// - replace this header by the LICENSE.txt content.
7
8
#pragma once
9
10
#include <cmath>
11
#include <iostream>
12
13
namespace
OpenMEEG
{
14
#ifndef USE_PROGRESSBAR
15
class
ProgressBar
{
16
public
:
17
18
ProgressBar
(
const
unsigned
n,
const
unsigned
sz=20): max_iter(n),bar_size(sz) { }
19
20
void
operator++
() {
21
const
unsigned
p = std::min(
static_cast<
unsigned
>
(floor(
static_cast<
double
>
((bar_size+1)*iter++)/max_iter)),bar_size);
22
if
(p!=pprev && iter>1) {
23
std::cout << std::string(bar_size+2,
'\b'
) <<
'['
<< std::string(p,
'*'
) << std::string(bar_size-p,
'.'
) <<
']'
;
24
pprev = p;
25
}
26
if
(iter>=max_iter)
27
std::cout << std::endl;
28
std::cout.flush();
29
}
30
31
private
:
32
33
unsigned
iter = 0;
34
unsigned
pprev = -1;
35
const
unsigned
max_iter;
36
const
unsigned
bar_size;
37
};
38
#else
39
class
ProgressBar {
40
public
:
41
42
ProgressBar(
const
unsigned
,
const
unsigned
=20) { }
43
void
operator++
() { }
44
};
45
#endif
46
}
OpenMEEG::ProgressBar
Definition:
progressbar.h:15
OpenMEEG::ProgressBar::ProgressBar
ProgressBar(const unsigned n, const unsigned sz=20)
Definition:
progressbar.h:18
OpenMEEG::ProgressBar::operator++
void operator++()
Definition:
progressbar.h:20
OpenMEEG
Definition:
analytics.h:14
Generated by
1.9.6