LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::ProgressMonitor Class Reference

Description

Stores and updates current progress of computation in a location shared between the library and WL Kernel.

ProgressMonitor receives an instance of a shared Tensor<double> in constructor and becomes the (shared) owner. Progress is a single number of type double between 0. and 1. This class offers an interface for modifying the progress value (increase/decrease by a given step or set to an arbitrary value) and one static function for checking if a user requested to abort the computation in WL Kernel.

#include <ProgressMonitor.h>

Public Types

using SharedTensor = Tensor< double >
 A type to represent a buffer shared between LLU and the Kernel which is used to report progress. More...
 

Public Member Functions

 ProgressMonitor (SharedTensor sharedIndicator, double step=defaultStep)
 Construct a new ProgressMonitor. More...
 
 ProgressMonitor (const ProgressMonitor &)=delete
 Copy-constructor is disabled because ProgressMonitor shares a Tensor with WL Kernel. More...
 
ProgressMonitoroperator= (const ProgressMonitor &)=delete
 Copy-assignment is disabled because ProgressMonitor shares a Tensor with WL Kernel. More...
 
 ProgressMonitor (ProgressMonitor &&)=default
 Default move-constructor. More...
 
ProgressMonitoroperator= (ProgressMonitor &&)=default
 Default move-assignment operator. More...
 
 ~ProgressMonitor ()=default
 Default destructor. More...
 
double get () const
 Get current value of the progress. More...
 
void set (double progressValue)
 Set current progress value. More...
 
double getStep () const
 Get current step value. More...
 
void setStep (double stepValue)
 Change step value to a given number. More...
 
ProgressMonitoroperator++ ()
 Increment current progress value by step. More...
 
ProgressMonitoroperator+= (double progress)
 Increment current progress value by a given number. More...
 
ProgressMonitoroperator-- ()
 Decrement current progress value by step. More...
 
ProgressMonitoroperator-= (double progress)
 Decrement current progress value by a given number. More...
 

Static Public Member Functions

static void checkAbort ()
 Check whether user requested to abort the computation in WL Kernel. More...
 
static constexpr double getDefaultStep () noexcept
 Return default step for the ProgressMonitor. More...
 

Type aliases documentation

◆ SharedTensor

A type to represent a buffer shared between LLU and the Kernel which is used to report progress.

Constructor & Destructor Documentation

◆ ProgressMonitor() [1/3]

LLU::ProgressMonitor::ProgressMonitor ( SharedTensor  sharedIndicator,
double  step = defaultStep 
)
explicit

Construct a new ProgressMonitor.

Parameters
sharedIndicator- shared Tensor of type double. If tensor length is smaller than 1, the behavior is undefined.
step- by how much to modify the progress value in operator++ and operator--

◆ ProgressMonitor() [2/3]

LLU::ProgressMonitor::ProgressMonitor ( const ProgressMonitor )
delete

Copy-constructor is disabled because ProgressMonitor shares a Tensor with WL Kernel.

◆ ProgressMonitor() [3/3]

LLU::ProgressMonitor::ProgressMonitor ( ProgressMonitor &&  )
default

Default move-constructor.

◆ ~ProgressMonitor()

LLU::ProgressMonitor::~ProgressMonitor ( )
default

Default destructor.

Member Function Documentation

◆ checkAbort()

void LLU::ProgressMonitor::checkAbort ( )
static

Check whether user requested to abort the computation in WL Kernel.

◆ get()

double LLU::ProgressMonitor::get ( ) const

Get current value of the progress.

Returns
current value of the progress (a double between 0. and 1.)

◆ getDefaultStep()

static constexpr double LLU::ProgressMonitor::getDefaultStep ( )
inlinestaticconstexprnoexcept

Return default step for the ProgressMonitor.

Returns
default step value (0.1)

◆ getStep()

double LLU::ProgressMonitor::getStep ( ) const

Get current step value.

Returns
current step value

◆ operator++()

ProgressMonitor & LLU::ProgressMonitor::operator++ ( )

Increment current progress value by step.

Returns
self

◆ operator+=()

ProgressMonitor & LLU::ProgressMonitor::operator+= ( double  progress)

Increment current progress value by a given number.

Parameters
progress- a real number between 0. and (1 - get()). No validation is done.
Returns
self

◆ operator--()

ProgressMonitor & LLU::ProgressMonitor::operator-- ( )

Decrement current progress value by step.

Returns
self

◆ operator-=()

ProgressMonitor & LLU::ProgressMonitor::operator-= ( double  progress)

Decrement current progress value by a given number.

Parameters
progress- a real number between 0. and get(). No validation is done.
Returns
self

◆ operator=() [1/2]

ProgressMonitor& LLU::ProgressMonitor::operator= ( const ProgressMonitor )
delete

Copy-assignment is disabled because ProgressMonitor shares a Tensor with WL Kernel.

◆ operator=() [2/2]

ProgressMonitor& LLU::ProgressMonitor::operator= ( ProgressMonitor &&  )
default

Default move-assignment operator.

◆ set()

void LLU::ProgressMonitor::set ( double  progressValue)

Set current progress value.

Parameters
progressValue- current progress (a double between 0. and 1.)

◆ setStep()

void LLU::ProgressMonitor::setStep ( double  stepValue)

Change step value to a given number.

Parameters
stepValue- any real number between 0. and 1.