libcrn
3.9.5
A document image processing library
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
libcrn
CRNUtils
CRNProgress.cpp
Go to the documentation of this file.
1
/* Copyright 2007-2013 Yann LEYDIER, INSA-Lyon
2
*
3
* This file is part of libcrn.
4
*
5
* libcrn is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* libcrn is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17
*
18
* file: CRNProgress.cpp
19
* \author Yann LEYDIER
20
*/
21
22
#include <
CRNUtils/CRNProgress.h
>
23
#include <
CRNIO/CRNIO.h
>
24
#include <
CRNMath/CRNMath.h
>
25
#include <cstdio>
26
27
using namespace
crn;
28
29
/*****************************************************************************/
34
void
Progress::Advance
()
35
{
36
current
+= 1;
37
double
f = (double(
current
) * 100.0) / double(
end
);
38
char
buff[1024];
39
switch
(
type
)
40
{
41
case
Type::ABSOLUTE
:
42
snprintf(buff, 1024,
" %zi / %zi"
,
Min
(
current
+ 1,
end
),
end
);
43
break
;
44
case
Type::PERCENT
:
45
default
:
46
snprintf(buff, 1024,
" %.2f %%"
, (
double
)f);
47
break
;
48
}
49
disp
=
name
+ buff;
50
display
(
disp
);
51
}
52
53
void
Progress::Reset
()
54
{
55
current
= -1;
56
Advance
();
57
}
58
59
Progress::~Progress
()
60
{
61
}
62
63
void
ConsoleProgress::display
(
const
String
&msg)
64
{
65
CRNVerbose
(msg);
66
}
67
CRNMath.h
CRNIO.h
crn::Progress::Type::PERCENT
crn::Progress::current
size_t current
Definition:
CRNProgress.h:70
crn::Progress::Advance
void Advance()
Progresses of one step.
Definition:
CRNProgress.cpp:34
crn::String
A UTF32 character string class.
Definition:
CRNString.h:61
crn::Progress::end
size_t end
Definition:
CRNProgress.h:71
CRNProgress.h
crn::Progress::disp
String disp
Definition:
CRNProgress.h:72
crn::Progress::Type::ABSOLUTE
crn::Min
const T & Min(const T &a, const T &b)
Returns the min of two values.
Definition:
CRNMath.h:49
crn::Progress::Reset
void Reset()
Resets the progress to 0.
Definition:
CRNProgress.cpp:53
crn::Progress::~Progress
virtual ~Progress()
Destructor.
Definition:
CRNProgress.cpp:59
crn::Progress::display
virtual void display(const String &msg)=0
Displays the progress.
crn::ConsoleProgress::display
virtual void display(const String &msg) override
Displays the progress.
Definition:
CRNProgress.cpp:63
crn::Progress::name
String name
Definition:
CRNProgress.h:69
CRNVerbose
#define CRNVerbose(x)
Definition:
CRNIO.h:146
crn::Progress::type
Type type
Definition:
CRNProgress.h:73
Generated on Thu Sep 7 2017 13:54:26 for libcrn by
1.8.6