Default progress is now infinite. Finite is moved to new class
This commit is contained in:
53
ProgressFinite.cpp
Normal file
53
ProgressFinite.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "ProgressFinite.h"
|
||||
#include <sstream>
|
||||
|
||||
using std::ostream;
|
||||
using std::string;
|
||||
using std::stringstream;
|
||||
|
||||
ProgressFinite::ProgressFinite(const string& message, size_t total, size_t current)
|
||||
: Progress(message, current),
|
||||
m_total(total)
|
||||
{
|
||||
if (m_current > m_total)
|
||||
{
|
||||
m_current = m_total;
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressFinite::set_total(size_t total)
|
||||
{
|
||||
m_total = total;
|
||||
|
||||
if (m_current > m_total)
|
||||
{
|
||||
m_current = m_total;
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressFinite::set_progress(size_t current)
|
||||
{
|
||||
m_current = current;
|
||||
|
||||
if (m_current > m_total)
|
||||
{
|
||||
m_current = m_total;
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressFinite::increment_progress(size_t inc)
|
||||
{
|
||||
m_current += inc;
|
||||
|
||||
if (m_current > m_total)
|
||||
{
|
||||
m_current = m_total;
|
||||
}
|
||||
}
|
||||
|
||||
string ProgressFinite::print_progress() const
|
||||
{
|
||||
stringstream out;
|
||||
out << m_current << "/" << m_total << " - " << m_message;
|
||||
return out.str();
|
||||
}
|
||||
Reference in New Issue
Block a user