Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ProgressLog Class Reference

Progress Logger that writes the progress using the LOG macro. More...

#include <ored/utilities/progressbar.hpp>

+ Inheritance diagram for ProgressLog:
+ Collaboration diagram for ProgressLog:

Public Member Functions

 ProgressLog (const std::string &message, const unsigned int numberOfMessages=100, const oreSeverity logLevel=oreSeverity::debug)
 
void updateProgress (const unsigned long progress, const unsigned long total, const std::string &detail) override
 ProgressIndicator interface. More...
 
void reset () override
 
- Public Member Functions inherited from ProgressIndicator
 ProgressIndicator ()
 
virtual ~ProgressIndicator ()
 
virtual void updateProgress (const unsigned long progress, const unsigned long total, const std::string &detail)=0
 
virtual void reset ()=0
 

Private Attributes

std::string key_
 
unsigned int numberOfMessages_
 
oreSeverity logLevel_
 
unsigned int messageCounter_
 

Detailed Description

Progress Logger that writes the progress using the LOG macro.

Definition at line 103 of file progressbar.hpp.

Constructor & Destructor Documentation

◆ ProgressLog()

ProgressLog ( const std::string &  message,
const unsigned int  numberOfMessages = 100,
const oreSeverity  logLevel = oreSeverity::debug 
)

Definition at line 98 of file progressbar.cpp.

99 : key_(message), numberOfMessages_(numberOfMessages), logLevel_(logLevel), messageCounter_(0) {}
unsigned int numberOfMessages_
unsigned int messageCounter_

Member Function Documentation

◆ updateProgress()

void updateProgress ( const unsigned long  progress,
const unsigned long  total,
const std::string &  detail 
)
overridevirtual

ProgressIndicator interface.

Implements ProgressIndicator.

Definition at line 101 of file progressbar.cpp.

101 {
102 if (messageCounter_ > 0 && progress * numberOfMessages_ < (messageCounter_ * total)) {
103 return;
104 }
105 MLOG(logLevel_, key_ << " (" << detail << "): " << progress << " out of " << total << " steps ("
106 << static_cast<int>(static_cast<double>(progress) / static_cast<double>(total) * 100.0)
107 << "%) completed");
108 ProgressMessage(key_, progress, total, detail).log();
110}
#define MLOG(mask, text)
Definition: log.hpp:529
+ Here is the call graph for this function:

◆ reset()

void reset ( )
overridevirtual

Implements ProgressIndicator.

Definition at line 112 of file progressbar.cpp.

112{ messageCounter_ = 0; }

Member Data Documentation

◆ key_

std::string key_
private

Definition at line 113 of file progressbar.hpp.

◆ numberOfMessages_

unsigned int numberOfMessages_
private

Definition at line 114 of file progressbar.hpp.

◆ logLevel_

oreSeverity logLevel_
private

Definition at line 115 of file progressbar.hpp.

◆ messageCounter_

unsigned int messageCounter_
private

Definition at line 116 of file progressbar.hpp.