Progress.hpp
Go to the documentation of this file.
1 
28  /*
29  * ProgressBar.h
30  *
31  * Created on: 14.01.2011
32  * Author: Thomas Wiemann
33  */
34 
35 #ifndef LVR2_PROGRESSBARQT_H_
36 #define LVR2_PROGRESSBARQT_H_
37 
38 #include <string>
39 #include <sstream>
40 #include <iostream>
41 
42 using std::stringstream;
43 using std::cout;
44 using std::endl;
45 using std::flush;
46 using std::string;
47 using std::wstring;
48 using std::wcout;
49 
50 #include <boost/thread/mutex.hpp>
51 
52 namespace lvr2
53 {
54 
65 typedef void(*ProgressCallbackPtr)(int);
66 typedef void(*ProgressTitleCallbackPtr)(string);
67 
69 {
70 
71 public:
72 
79  ProgressBar(size_t max_val, string prefix = "");
80 
81  virtual ~ProgressBar();
82 
86  void operator++();
87 
91  void operator+=(size_t n);
92 
93 
101 
108 
109 protected:
110 
112  void print_bar();
113 
115  string m_prefix;
116 
118  size_t m_maxVal;
119 
121  size_t m_currentVal;
122 
124  boost::mutex m_mutex;
125 
128 
130  stringstream m_stream;
131 
133  string m_fillstring;
134 
137 };
138 
139 
148 {
149 public:
150 
151  /***
152  * @brief CTor.
153  *
154  * @param stepVal After m_stepVal operations a new output is generated
155  * @param prefix The prefix string for progress output
156  */
157  ProgressCounter(int stepVal, string prefix = "");
158 
159  /***
160  * @brief Increase the progress counter
161  */
162  void operator++();
163 
164 protected:
165 
167  void print_progress();
168 
170  string m_prefix;
171 
173  size_t m_stepVal;
174 
176  size_t m_currentVal;
177 
179  boost::mutex m_mutex;
180 
182  stringstream m_stream;
183 
185  string m_fillstring;
186 };
187 
188 
199 typedef void(*PacmanProgressCallbackPtr)(int);
200 typedef void(*PacmanProgressTitleCallbackPtr)(string);
201 
203 {
204 
205 public:
206 
213  PacmanProgressBar(size_t max_val, string prefix = "", size_t bar_length = 60 );
214 
215  virtual ~PacmanProgressBar();
216 
220  void operator++();
221 
229 
236 
237 protected:
238 
240  void print_bar();
241 
243  string m_prefix;
244 
246  size_t m_maxVal;
247 
249  size_t m_currentVal;
250 
252  boost::mutex m_mutex;
253 
256 
257  // bar length
259 
261  stringstream m_stream;
262 
264  string m_fillstring;
265 
268 };
269 
270 } // namespace lvr2
271 
272 #endif /* PROGRESSBAR_H_ */
string m_prefix
The prefix string.
Definition: Progress.hpp:115
static PacmanProgressTitleCallbackPtr m_titleCallback
Definition: Progress.hpp:267
void(* PacmanProgressCallbackPtr)(int)
A class to manage progress information output for process where the number of performed operations is...
Definition: Progress.hpp:199
int m_percent
The current progress in percent.
Definition: Progress.hpp:127
void(* ProgressCallbackPtr)(int)
A class to manage progress information output for process where the number of performed operations is...
Definition: Progress.hpp:65
size_t m_maxVal
The number of iterations.
Definition: Progress.hpp:118
static PacmanProgressCallbackPtr m_progressCallback
Definition: Progress.hpp:266
size_t m_currentVal
The current counter.
Definition: Progress.hpp:121
ProgressBar(size_t max_val, string prefix="")
Ctor.
Definition: Progress.cpp:52
void print_bar()
Prints the output.
Definition: Progress.cpp:133
string m_prefix
The prefix string.
Definition: Progress.hpp:243
void(* ProgressTitleCallbackPtr)(string)
Definition: Progress.hpp:66
boost::mutex m_mutex
A mutex object for counter increment (for parallel executions)
Definition: Progress.hpp:179
size_t m_maxVal
The number of iterations.
Definition: Progress.hpp:246
virtual ~ProgressBar()
Definition: Progress.cpp:68
string m_fillstring
A fill string for correct output alignment.
Definition: Progress.hpp:185
void operator+=(size_t n)
Increases the counter of performed by n.
Definition: Progress.cpp:108
size_t m_currentVal
The current counter.
Definition: Progress.hpp:249
string m_fillstring
A fill string for correct output alignment.
Definition: Progress.hpp:264
stringstream m_stream
A string stream for output generation.
Definition: Progress.hpp:182
void(* PacmanProgressTitleCallbackPtr)(string)
Definition: Progress.hpp:200
static ProgressCallbackPtr m_progressCallback
Definition: Progress.hpp:135
stringstream m_stream
A string stream for output generation.
Definition: Progress.hpp:261
static ProgressTitleCallbackPtr m_titleCallback
Definition: Progress.hpp:136
static void setProgressCallback(ProgressCallbackPtr)
Registers a callback that is called with the new value when the percentage of the progress changed...
Definition: Progress.cpp:73
int m_percent
The current progress in percent.
Definition: Progress.hpp:255
static void setProgressTitleCallback(ProgressTitleCallbackPtr)
Registers a callback that is called when a new progress instance is created.
Definition: Progress.cpp:78
A progress counter class.
Definition: Progress.hpp:147
string m_prefix
The prefix string.
Definition: Progress.hpp:170
void operator++()
Increases the counter of performed iterations.
Definition: Progress.cpp:83
boost::mutex m_mutex
A mutex object for counter increment (for parallel executions)
Definition: Progress.hpp:252
stringstream m_stream
A string stream for output generation.
Definition: Progress.hpp:130
string m_fillstring
A fill string for correct output alignment.
Definition: Progress.hpp:133
boost::mutex m_mutex
A mutex object for counter increment (for parallel executions)
Definition: Progress.hpp:124
size_t m_currentVal
The current counter value.
Definition: Progress.hpp:176
size_t m_stepVal
The step value for output generation.
Definition: Progress.hpp:173


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08