OpenWalnut
1.3.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
src
core
common
WProgress.h
1
//---------------------------------------------------------------------------
2
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
7
//
8
// This file is part of OpenWalnut.
9
//
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22
//
23
//---------------------------------------------------------------------------
24
25
#ifndef WPROGRESS_H
26
#define WPROGRESS_H
27
28
#include <set>
29
#include <string>
30
31
#include <boost/shared_ptr.hpp>
32
33
34
/**
35
* Class managing progress inside of modules. It interacts with the abstract WGUI class to present those information to the user.
36
* At the same time, it also is a simple tree structure, allowing the programmer to arrange complex sub progress. This is
37
* especially useful if several time-consuming tasks need to be performed.
38
*
39
* \see WGUI
40
*/
41
class
WProgress
// NOLINT
42
{
43
friend
class
WProgressTest
;
44
public
:
45
/**
46
* Shared pointer on a WProgress
47
*/
48
typedef
boost::shared_ptr< WProgress >
SPtr
;
49
50
/**
51
* Const Shared pointer on a WProgress
52
*/
53
typedef
boost::shared_ptr< const WProgress >
ConstSPtr
;
54
55
/**
56
* Creates a new progress instance as child of the specified progress. The instance is instantly marked "running".
57
*
58
* \param name name of the progress, can be empty.
59
* \param count value denoting the final value. A value of zero will cause this progress to be indetermined.
60
*
61
* \note Reaching the count does not automatically stop the progress. You still need to call finish().
62
* \note An indetermined progress is just indicating a pending progress without progress information.
63
*/
64
WProgress
( std::string name,
size_t
count = 0 );
65
66
/**
67
* Destructor.
68
*/
69
virtual
~WProgress
();
70
71
/**
72
* Stops the progress. After finishing, the progress de-registers from its parent (if any).
73
*/
74
virtual
void
finish
();
75
76
/**
77
* Simple increment operator to signal a forward stepping.
78
*
79
* \note this actually is for ++p. p++ is not useful since it returns a copy of WProgress with the old count.
80
*
81
* \return the incremented WProgress instance.
82
*/
83
virtual
WProgress
&
operator++
();
84
85
/**
86
* Increments the operator by the given number of steps to signal forward progress.
87
*
88
* \param steps The number of steps to increment
89
*
90
* \return the incremented WProgress instance.
91
*/
92
virtual
WProgress
&
operator+
(
size_t
steps );
93
94
/**
95
* Returns the overall progress of this progress instance, including the child progress'.
96
*
97
* \return the progress.
98
*/
99
virtual
float
getProgress
();
100
101
/**
102
* Returns true when the operation is pending. After calling finish() this will always return false.
103
*
104
* \return true if not finished.
105
*/
106
virtual
bool
isPending
();
107
108
/**
109
* Returns the name of the progress.
110
*
111
* \return name
112
*/
113
std::string
getName
()
const
;
114
115
/**
116
* Function updating the internal state. This needs to be called before any get function to ensure the getter return the right
117
* values.
118
*/
119
virtual
void
update
();
120
121
/**
122
* Returns true whenever the progress has a known end. If this instance has m_max==0 then this will be false, as there is no
123
* known end point.
124
*
125
* \return false if no end point is known.
126
*/
127
virtual
bool
isDetermined
();
128
129
/**
130
* Increment the progress counter by the given amount.
131
*
132
* \param steps how much
133
*/
134
virtual
void
increment
(
size_t
steps );
135
136
protected
:
137
/**
138
* Progress name. Can be set only once (during construction).
139
*/
140
std::string
m_name
;
141
142
/**
143
* The maximum count (which marks the 100%).
144
*/
145
size_t
m_max
;
146
147
/**
148
* The current counter.
149
*/
150
size_t
m_count
;
151
152
/**
153
* Flag denoting whether the progress is running or not.
154
*/
155
bool
m_pending
;
156
157
/**
158
* True if the progress has a known end point.
159
*/
160
bool
m_determined
;
161
162
private
:
163
};
164
165
#endif // WPROGRESS_H
166
Generated by
1.8.3.1