24 #ifndef _TPIE_PROGRESS_INDICATOR_BASE_H
25 #define _TPIE_PROGRESS_INDICATOR_BASE_H
29 #include <boost/thread.hpp>
36 enum description_importance {
94 ticks currentTicks = getticks();
95 if (elapsed(currentTicks,m_lastCalled) > m_frequency * m_threshold * 5)
97 << (elapsed(currentTicks,m_lastCalled) / (m_frequency * m_threshold))
98 <<
" seconds" << std::endl;;
99 m_lastCalled = currentTicks;
103 ticks currentTicks = getticks();
104 m_next =
static_cast<stream_size_type
>(
105 static_cast<double>(
m_current) * (elapsed(currentTicks, m_start) + m_threshold)/
106 elapsed(currentTicks, m_start));
112 void raw_step(stream_size_type
step) {
115 m_lastCalled = getticks();
124 virtual void init(stream_size_type range=0) {
129 m_start = getticks();
133 m_lastCalled = getticks();
170 void set_time_predictor(execution_time_predictor * p) {m_predictor = p;}
172 std::string estimated_remaining_time() {
173 if (
m_range == 0 || m_predictor == 0)
return "";
174 return m_predictor->estimate_remaining_time(
double(
m_current) /
double(
m_range) );
177 virtual void push_breadcrumb(
const char *, description_importance) {}
178 virtual void pop_breadcrumb() {}
192 stream_size_type m_next;
196 static const unsigned int m_frequency;
199 static double m_threshold;
202 static bool m_thresholdComputed;
208 static void compute_threshold();
216 #endif // _TPIE_PROGRESS_INDICATOR_BASE
The base class for indicating the progress of some task.
virtual void refresh()=0
Display the indicator.
stream_size_type get_range()
Get the maximum value of the current range.
Machine-dependent cycle counters code by Matteo Frigo at MIT.
virtual ~progress_indicator_base()
The destructor. Nothing is done.
Execution time predictor used by fractional progress.
virtual void done()
Advance the indicator to the end.
stream_size_type m_current
The current progress count [m_minRange...m_maxRange].
This file contains a few deprecated definitions for legacy code.
Logging functionality and log_level codes for different priorities of log messages.
stream_size_type m_range
The upper bound of the counting range.
virtual void set_range(stream_size_type range)
Set the upper bound of the counting range.
void step(stream_size_type step=1)
Record an increment to the indicator and advance the indicator.
progress_indicator_base(stream_size_type range)
Initializes the indicator.
stream_size_type get_current()
Get the current value of the step counter.
logstream & log_debug()
Return logstream for writing debug log messages.
virtual void init(stream_size_type range=0)
Initialize progress indicator.