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_ */
lvr2::ProgressCounter::ProgressCounter
ProgressCounter(int stepVal, string prefix="")
Definition: Progress.cpp:138
lvr2::ProgressBar
Definition: Progress.hpp:68
lvr2::ProgressCounter::m_fillstring
string m_fillstring
A fill string for correct output alignment.
Definition: Progress.hpp:185
lvr2::ProgressBar::m_stream
stringstream m_stream
A string stream for output generation.
Definition: Progress.hpp:130
lvr2::PacmanProgressBar::setProgressTitleCallback
static void setProgressTitleCallback(ProgressTitleCallbackPtr)
Registers a callback that is called when a new progress instance is created.
Definition: Progress.cpp:191
lvr2::ProgressCounter::m_stream
stringstream m_stream
A string stream for output generation.
Definition: Progress.hpp:182
lvr2::ProgressCounter::m_stepVal
size_t m_stepVal
The step value for output generation.
Definition: Progress.hpp:173
lvr2::ProgressBar::m_titleCallback
static ProgressTitleCallbackPtr m_titleCallback
Definition: Progress.hpp:136
lvr2::ProgressCounter::operator++
void operator++()
Definition: Progress.cpp:145
lvr2::ProgressBar::setProgressTitleCallback
static void setProgressTitleCallback(ProgressTitleCallbackPtr)
Registers a callback that is called when a new progress instance is created.
Definition: Progress.cpp:78
lvr2::ProgressBar::m_fillstring
string m_fillstring
A fill string for correct output alignment.
Definition: Progress.hpp:133
lvr2::PacmanProgressBar::PacmanProgressBar
PacmanProgressBar(size_t max_val, string prefix="", size_t bar_length=60)
Ctor.
Definition: Progress.cpp:163
lvr2::ProgressBar::operator+=
void operator+=(size_t n)
Increases the counter of performed by n.
Definition: Progress.cpp:108
lvr2::ProgressBar::m_maxVal
size_t m_maxVal
The number of iterations.
Definition: Progress.hpp:118
lvr2::ProgressBar::ProgressBar
ProgressBar(size_t max_val, string prefix="")
Ctor.
Definition: Progress.cpp:52
lvr2::ProgressBar::m_percent
int m_percent
The current progress in percent.
Definition: Progress.hpp:127
lvr2::ProgressBar::setProgressCallback
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
lvr2::ProgressBar::print_bar
void print_bar()
Prints the output.
Definition: Progress.cpp:133
lvr2::ProgressCounter::m_prefix
string m_prefix
The prefix string.
Definition: Progress.hpp:170
lvr2::PacmanProgressBar::m_progressCallback
static PacmanProgressCallbackPtr m_progressCallback
Definition: Progress.hpp:266
lvr2::PacmanProgressBar::setProgressCallback
static void setProgressCallback(ProgressCallbackPtr)
Registers a callback that is called with the new value when the percentage of the progress changed.
Definition: Progress.cpp:186
lvr2::PacmanProgressBar::operator++
void operator++()
Increases the counter of performed iterations.
Definition: Progress.cpp:196
lvr2::PacmanProgressBar::~PacmanProgressBar
virtual ~PacmanProgressBar()
Definition: Progress.cpp:181
lvr2::PacmanProgressBar::m_maxVal
size_t m_maxVal
The number of iterations.
Definition: Progress.hpp:246
lvr2::PacmanProgressBar::m_currentVal
size_t m_currentVal
The current counter.
Definition: Progress.hpp:249
lvr2::ProgressCounter::m_currentVal
size_t m_currentVal
The current counter value.
Definition: Progress.hpp:176
lvr2::PacmanProgressBar::m_prefix
string m_prefix
The prefix string.
Definition: Progress.hpp:243
lvr2::ProgressBar::m_currentVal
size_t m_currentVal
The current counter.
Definition: Progress.hpp:121
lvr2::PacmanProgressBar::print_bar
void print_bar()
Prints the output.
Definition: Progress.cpp:222
lvr2::PacmanProgressCallbackPtr
void(* PacmanProgressCallbackPtr)(int)
A class to manage progress information output for process where the number of performed operations is...
Definition: Progress.hpp:199
lvr2::PacmanProgressBar
Definition: Progress.hpp:202
lvr2::PacmanProgressBar::m_percent
int m_percent
The current progress in percent.
Definition: Progress.hpp:255
lvr2::ProgressBar::operator++
void operator++()
Increases the counter of performed iterations.
Definition: Progress.cpp:83
scripts.create_png.max_val
max_val
Definition: create_png.py:35
lvr2::PacmanProgressBar::m_stream
stringstream m_stream
A string stream for output generation.
Definition: Progress.hpp:261
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::ProgressCallbackPtr
void(* ProgressCallbackPtr)(int)
A class to manage progress information output for process where the number of performed operations is...
Definition: Progress.hpp:65
lvr2::PacmanProgressBar::m_fillstring
string m_fillstring
A fill string for correct output alignment.
Definition: Progress.hpp:264
lvr2::ProgressCounter::m_mutex
boost::mutex m_mutex
A mutex object for counter increment (for parallel executions)
Definition: Progress.hpp:179
lvr2::ProgressBar::~ProgressBar
virtual ~ProgressBar()
Definition: Progress.cpp:68
lvr2::ProgressBar::m_prefix
string m_prefix
The prefix string.
Definition: Progress.hpp:115
lvr2::PacmanProgressBar::m_titleCallback
static PacmanProgressTitleCallbackPtr m_titleCallback
Definition: Progress.hpp:267
lvr2::ProgressCounter
A progress counter class.
Definition: Progress.hpp:147
lvr2::PacmanProgressBar::m_mutex
boost::mutex m_mutex
A mutex object for counter increment (for parallel executions)
Definition: Progress.hpp:252
lvr2::PacmanProgressBar::m_bar_length
int m_bar_length
Definition: Progress.hpp:258
lvr2::ProgressBar::m_mutex
boost::mutex m_mutex
A mutex object for counter increment (for parallel executions)
Definition: Progress.hpp:124
lvr2::ProgressCounter::print_progress
void print_progress()
Prints the current state.
Definition: Progress.cpp:155
lvr2::PacmanProgressTitleCallbackPtr
void(* PacmanProgressTitleCallbackPtr)(string)
Definition: Progress.hpp:200
lvr2::ProgressTitleCallbackPtr
void(* ProgressTitleCallbackPtr)(string)
Definition: Progress.hpp:66
lvr2::ProgressBar::m_progressCallback
static ProgressCallbackPtr m_progressCallback
Definition: Progress.hpp:135


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 Wed Mar 2 2022 00:37:24