Commit 64afd2ec authored by Davis King's avatar Davis King

Made the console_progress_indicator::print_status() method return

a bool indicating if it actually printed anything.
parent 2bf68f2c
...@@ -64,7 +64,7 @@ namespace dlib ...@@ -64,7 +64,7 @@ namespace dlib
function returns that targeted value. function returns that targeted value.
!*/ !*/
inline void print_status ( inline bool print_status (
double cur double cur
); );
/*! /*!
...@@ -74,8 +74,12 @@ namespace dlib ...@@ -74,8 +74,12 @@ namespace dlib
remaining until cur becomes equal to target(). remaining until cur becomes equal to target().
- prints a status message to the screen which indicates how much - prints a status message to the screen which indicates how much
more time is left until cur is equal to target() more time is left until cur is equal to target()
- this function throttles the printing so that at most 1 message is - This function throttles the printing so that at most 1 message is printed
printed each second. each second. Note that it won't print anything to the screen until about
one second has elapsed. This means that the first call to print_status()
never prints to the screen.
- This function returns true if it prints to the screen and false
otherwise.
!*/ !*/
private: private:
...@@ -109,7 +113,7 @@ namespace dlib ...@@ -109,7 +113,7 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void console_progress_indicator:: bool console_progress_indicator::
print_status ( print_status (
double cur double cur
) )
...@@ -125,7 +129,7 @@ namespace dlib ...@@ -125,7 +129,7 @@ namespace dlib
last_time = cur_time; last_time = cur_time;
first_val = cur; first_val = cur;
seen_first_val = true; seen_first_val = true;
return; return false;
} }
if (cur_time != last_time) if (cur_time != last_time)
...@@ -136,7 +140,7 @@ namespace dlib ...@@ -136,7 +140,7 @@ namespace dlib
// don't do anything if cur is equal to first_val // don't do anything if cur is equal to first_val
if (delta_val < std::numeric_limits<double>::epsilon()) if (delta_val < std::numeric_limits<double>::epsilon())
return; return false;
double seconds = delta_t/delta_val * std::abs(target_val - cur); double seconds = delta_t/delta_val * std::abs(target_val - cur);
...@@ -164,7 +168,11 @@ namespace dlib ...@@ -164,7 +168,11 @@ namespace dlib
// restore previous output flags and precision settings // restore previous output flags and precision settings
std::cout.flags(oldflags); std::cout.flags(oldflags);
std::cout.precision(ss); std::cout.precision(ss);
return true;
} }
return false;
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment