presage
0.9.1
src
lib
core
progress.h
Go to the documentation of this file.
1
2
/******************************************************
3
* Presage, an extensible predictive text entry system
4
* ---------------------------------------------------
5
*
6
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
7
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License along
19
with this program; if not, write to the Free Software Foundation, Inc.,
20
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
*
22
**********(*)*/
23
24
25
#ifndef PROGRESS_H
26
#define PROGRESS_H
27
28
#include <iostream>
29
30
template
<
class
_
char
T,
class
_Traits=std::
char
_traits<_
char
T> >
31
class
ProgressBar
{
32
33
private
:
34
int
progress
;
35
int
quantum
;
36
std::basic_ostream<_charT,_Traits>&
outstream
;
37
38
public
:
39
ProgressBar
(std::basic_ostream<_charT,_Traits>& ostr = std::cout) :
outstream
(ostr)
40
{
41
progress
= 0;
42
quantum
= 2;
43
outstream
<<
"0---10---20---30---40---50---60---70---80---90--100"
<<
std::endl
;
44
}
45
46
~ProgressBar
()
47
{
48
for
(
int
i =
progress
; i <= 100; i +=
quantum
) {
49
outstream
<<
'#'
;
50
}
51
outstream
<<
std::endl
;
52
}
53
54
void
update
(
const
double
percentage)
55
{
56
if
((percentage*100) >=
progress
) {
57
progress
+=
quantum
;
58
outstream
<<
'#'
<< std::flush;
59
}
60
}
61
62
};
63
64
#endif
65
ProgressBar::~ProgressBar
~ProgressBar()
Definition:
progress.h:64
ProgressBar::update
void update(const double percentage)
Definition:
progress.h:72
ProgressBar::ProgressBar
ProgressBar(std::basic_ostream< _charT, _Traits > &ostr=std::cout)
Definition:
progress.h:57
ProgressBar::quantum
int quantum
Definition:
progress.h:53
ProgressBar::outstream
std::basic_ostream< _charT, _Traits > & outstream
Definition:
progress.h:54
ProgressBar::progress
int progress
Definition:
progress.h:52
endl
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)
Definition:
logger.h:277
ProgressBar
Definition:
progress.h:30
Generated on Sat Jan 25 2020 09:31:19 for presage by
1.8.16