Minsky
minsky::Progress Class Reference

#include <progress.h>

Collaboration diagram for minsky::Progress:
Collaboration graph

Public Member Functions

void displayProgress (bool inDestruct=false)
 
void increment (bool inDestruct=false)
 
void operator++ ()
 

Public Attributes

std::string title
 
std::shared_ptr< std::atomic< bool > > cancel =std::make_shared<std::atomic<bool>>(false)
 set to true to cancel process in progreess displayProgress will throw if cancel is set, but destructors should not throw, so set inDestruct to true when calling from a destructor More...
 

Private Attributes

double delta =100
 
double progress =0
 
bool updaterStack =false
 

Friends

class ProgressUpdater
 

Detailed Description

Definition at line 35 of file progress.h.

Member Function Documentation

◆ displayProgress()

void minsky::Progress::displayProgress ( bool  inDestruct = false)

Definition at line 1794 of file minsky.cc.

References cancel, minsky::minsky(), progress, minsky::Minsky::progress(), and title.

Referenced by increment(), minsky::ProgressUpdater::ProgressUpdater(), and minsky::ProgressUpdater::setProgress().

1795  {
1796  if (cancel && *cancel)
1797  {
1798  *cancel=false;
1799  if (!inDestruct) throw std::runtime_error("Cancelled");
1800  }
1801  minsky().progress(title, lround(progress));
1802  }
double progress
Definition: progress.h:38
std::shared_ptr< std::atomic< bool > > cancel
set to true to cancel process in progreess displayProgress will throw if cancel is set...
Definition: progress.h:43
std::string title
Definition: progress.h:42
virtual void progress(const std::string &title, int)
set progress bar, out of 100, labelling the progress bar with title
Definition: minsky.h:447
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ increment()

void minsky::Progress::increment ( bool  inDestruct = false)
inline

Definition at line 48 of file progress.h.

References delta, displayProgress(), and progress.

Referenced by operator++(), and minsky::ProgressUpdater::~ProgressUpdater().

48  {
49  if (progress+delta<=100)
50  {
51  progress+=delta;
52  displayProgress(inDestruct);
53  }
54  }
double progress
Definition: progress.h:38
void displayProgress(bool inDestruct=false)
Definition: minsky.cc:1794
double delta
Definition: progress.h:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator++()

void minsky::Progress::operator++ ( )
inline

Definition at line 55 of file progress.h.

References increment().

55 {increment();}
void increment(bool inDestruct=false)
Definition: progress.h:48
Here is the call graph for this function:

Friends And Related Function Documentation

◆ ProgressUpdater

friend class ProgressUpdater
friend

Definition at line 40 of file progress.h.

Member Data Documentation

◆ cancel

std::shared_ptr<std::atomic<bool> > minsky::Progress::cancel =std::make_shared<std::atomic<bool>>(false)

set to true to cancel process in progreess displayProgress will throw if cancel is set, but destructors should not throw, so set inDestruct to true when calling from a destructor

Definition at line 43 of file progress.h.

Referenced by displayProgress().

◆ delta

double minsky::Progress::delta =100
private

◆ progress

double minsky::Progress::progress =0
private

◆ title

std::string minsky::Progress::title

Definition at line 42 of file progress.h.

Referenced by displayProgress(), and minsky::ProgressUpdater::ProgressUpdater().

◆ updaterStack

bool minsky::Progress::updaterStack =false
private

The documentation for this class was generated from the following files: