54 lines
838 B
C++
54 lines
838 B
C++
#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();
|
|
}
|