39 i->updateProgress(progress, total, detail);
48 const QuantLib::Size barWidth,
const QuantLib::Size numberOfScreenUpdates)
49 : key_(message), messageWidth_(messageWidth), barWidth_(barWidth),
50 numberOfScreenUpdates_(numberOfScreenUpdates), updateCounter_(0), finalized_(false) {
56 if (!ConsoleLog::instance().enabled())
60 double ratio =
static_cast<double>(progress) /
static_cast<double>(total);
61 if (progress >= total) {
63 for (
unsigned int i = 0; i <
barWidth_; ++i)
77 unsigned int pos =
static_cast<unsigned int>(
static_cast<double>(
barWidth_) * ratio);
78 for (
unsigned int i = 0; i <
barWidth_; ++i) {
81 else if (i == pos && pos != 0)
88 std::cout << static_cast<int>(ratio * 100.0) <<
" %\r";
99 : key_(message), numberOfMessages_(numberOfMessages), logLevel_(logLevel), messageCounter_(0) {}
105 MLOG(
logLevel_,
key_ <<
" (" << detail <<
"): " << progress <<
" out of " << total <<
" steps ("
106 <<
static_cast<int>(
static_cast<double>(progress) /
static_cast<double>(total) * 100.0)
115 const std::set<QuantLib::ext::shared_ptr<ProgressIndicator>>& indicators)
116 : indicators_(indicators) {}
119 boost::unique_lock<boost::shared_mutex> lock(
mutex_);
120 threadData_[std::this_thread::get_id()] = std::make_tuple(progress, total, detail);
121 unsigned long progressTmp = 0;
122 unsigned long totalTmp = 0;
123 std::ostringstream detailTmp;
125 progressTmp += std::get<0>(d.second);
126 totalTmp += std::get<1>(d.second);
128 if (detailTmp.tellp() != 0)
130 detailTmp << std::get<2>(d.second);
133 i->updateProgress(progressTmp, totalTmp, detailTmp.str());
137 boost::unique_lock<boost::shared_mutex> lock(
mutex_);
144 std::cout << std::setw(messageWidth) << message << std::flush;
void log() const
generate Boost log record to pass to corresponding sinks
void updateProgress(const unsigned long progress, const unsigned long total, const std::string &detail) override
MultiThreadedProgressIndicator(const std::set< QuantLib::ext::shared_ptr< ProgressIndicator > > &indicators)
std::set< QuantLib::ext::shared_ptr< ProgressIndicator > > indicators_
std::map< std::thread::id, std::tuple< unsigned long, unsigned long, std::string > > threadData_
boost::shared_mutex mutex_
NoProgressBar(const std::string &message, const unsigned int messageWidth=40)
unsigned int numberOfMessages_
void updateProgress(const unsigned long progress, const unsigned long total, const std::string &detail) override
ProgressIndicator interface.
ProgressLog(const std::string &message, const unsigned int numberOfMessages=100, const oreSeverity logLevel=oreSeverity::debug)
unsigned int messageCounter_
void resetProgress()
reset
void unregisterProgressIndicator(const QuantLib::ext::shared_ptr< ProgressIndicator > &indicator)
unregister a Progress Indicator
void updateProgress(const unsigned long progress, const unsigned long total, const std::string &detail="")
update progress
std::set< QuantLib::ext::shared_ptr< ProgressIndicator > > indicators_
void registerProgressIndicator(const QuantLib::ext::shared_ptr< ProgressIndicator > &indicator)
register a Progress Indicator
void unregisterAllProgressIndicators()
unregister all progress indicators
void updateProgress(const unsigned long progress, const unsigned long total, const std::string &detail) override
ProgressIndicator interface.
unsigned int messageWidth_
unsigned int updateCounter_
unsigned int numberOfScreenUpdates_
SimpleProgressBar(const std::string &message, const QuantLib::Size messageWidth=40, const QuantLib::Size barWidth=40, const QuantLib::Size numberOfScreenUpdates=100)
Serializable Credit Default Swap.
Classes for progress reporting.