hej
is hosted by
Hepforge
,
IPPP Durham
HEJ 2
2.0
High energy resummation for hadron colliders
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
f
g
h
i
j
l
m
n
o
p
r
s
t
Variables
Typedefs
Enumerations
Enumerator
b
c
d
e
f
g
h
l
m
n
p
s
t
u
w
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
h
i
j
l
m
n
o
p
r
s
t
u
v
w
~
Functions
a
c
d
e
f
h
i
j
l
m
n
o
p
r
s
t
u
v
w
~
Variables
a
b
c
d
e
f
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Related Functions
Files
File List
File Members
All
c
h
j
m
o
Functions
c
j
m
o
Typedefs
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
include
HEJ
ProgressBar.hh
Go to the documentation of this file.
1
8
#pragma once
9
10
#include <ostream>
11
#include <functional>
12
#include <stdexcept>
13
14
namespace
HEJ
{
15
17
template
<
typename
T>
18
class
ProgressBar
{
19
public
:
21
27
ProgressBar
(std::ostream & out, T max) :
28
out_{out}, max_{max}
29
{
30
if
(max <= 0) {
31
throw
std::invalid_argument{
32
"Maximum in progress bar has to be positive"
33
};
34
}
35
print_bar();
36
}
37
39
46
ProgressBar
&
increment
(T count) {
47
counter_ += count;
48
update_progress();
49
return
*
this
;
50
}
51
53
58
ProgressBar
&
operator++
() {
59
++counter_;
60
update_progress();
61
return
*
this
;
62
}
63
64
private
:
65
void
update_progress() {
66
counter_ = std::min(counter_, max_);
67
const
int
ndots = (100*counter_)/max_;
68
const
int
new_dots = ndots - ndots_;
69
if
(new_dots > 0) {
70
for
(
int
dot = 0; dot < new_dots; ++dot) out_.get() <<
'.'
;
71
out_.get().flush();
72
ndots_ = ndots;
73
}
74
}
75
76
void
print_bar()
const
{
77
out_.get() <<
"0% "
;
78
for
(
int
i = 10; i <= 100; i+= 10){
79
out_.get() <<
" "
+
std::to_string
(i) +
"%"
;
80
}
81
out_.get() <<
"\n|"
;
82
for
(
int
i = 10; i <= 100; i+= 10){
83
out_.get() <<
"---------|"
;
84
}
85
out_.get() <<
'\n'
;
86
}
87
88
std::reference_wrapper<std::ostream> out_;
89
T counter_ = 0;
90
T ndots_ = 0;
91
T max_;
92
};
93
}
HEJ::ProgressBar
Class representing (and printing) a progress bar.
Definition:
ProgressBar.hh:18
HEJ::ProgressBar::operator++
ProgressBar & operator++()
Increase progress by one unit.
Definition:
ProgressBar.hh:58
HEJ::ProgressBar::increment
ProgressBar & increment(T count)
Increment progress.
Definition:
ProgressBar.hh:46
HEJ::ProgressBar::ProgressBar
ProgressBar(std::ostream &out, T max)
Constructor.
Definition:
ProgressBar.hh:27
HEJ
Main HEJ 2 Namespace.
Definition:
mainpage.dox:1
HEJ::to_string
std::string to_string(FileFormat f)
Convert a file format to a string.
Definition:
output_formats.hh:23
Generated by
1.9.1