LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
ProgressMonitor.h
Go to the documentation of this file.
1 
6 #ifndef LLU_PROGRESSMONITOR_H
7 #define LLU_PROGRESSMONITOR_H
8 
10 
11 namespace LLU {
12 
22  public:
25 
31  explicit ProgressMonitor(SharedTensor sharedIndicator, double step = defaultStep);
32 
34  ProgressMonitor(const ProgressMonitor&) = delete;
37 
42 
46  ~ProgressMonitor() = default;
47 
52  double get() const;
53 
58  void set(double progressValue);
59 
64  double getStep() const;
65 
70  void setStep(double stepValue);
71 
75  static void checkAbort();
76 
82 
88  ProgressMonitor& operator+=(double progress);
89 
95 
101  ProgressMonitor& operator-=(double progress);
102 
107  static constexpr double getDefaultStep() noexcept {
108  return defaultStep;
109  }
110  private:
112  static constexpr double defaultStep = .1;
113 
115  SharedTensor sharedIndicator;
116 
118  double step;
119  };
120 
121 } // namespace LLU
122 #endif // LLU_PROGRESSMONITOR_H
LLU::ProgressMonitor::ProgressMonitor
ProgressMonitor(const ProgressMonitor &)=delete
Copy-constructor is disabled because ProgressMonitor shares a Tensor with WL Kernel.
LLU::ProgressMonitor::SharedTensor
Tensor< double > SharedTensor
A type to represent a buffer shared between LLU and the Kernel which is used to report progress.
Definition: ProgressMonitor.h:24
LLU::ProgressMonitor::operator--
ProgressMonitor & operator--()
Decrement current progress value by step.
Definition: ProgressMonitor.cpp:49
LLU
Main namespace of LibraryLink Utilities.
Definition: Queue.h:13
LLU::ProgressMonitor::getStep
double getStep() const
Get current step value.
Definition: ProgressMonitor.cpp:24
LLU::ProgressMonitor::ProgressMonitor
ProgressMonitor(ProgressMonitor &&)=default
Default move-constructor.
LLU::Tensor< double >
LLU::ProgressMonitor::operator+=
ProgressMonitor & operator+=(double progress)
Increment current progress value by a given number.
Definition: ProgressMonitor.cpp:44
LLU::ProgressMonitor::ProgressMonitor
ProgressMonitor(SharedTensor sharedIndicator, double step=defaultStep)
Construct a new ProgressMonitor.
Definition: ProgressMonitor.cpp:13
LLU::ProgressMonitor::operator=
ProgressMonitor & operator=(ProgressMonitor &&)=default
Default move-assignment operator.
LLU::ProgressMonitor::setStep
void setStep(double stepValue)
Change step value to a given number.
Definition: ProgressMonitor.cpp:28
LLU::ProgressMonitor::checkAbort
static void checkAbort()
Check whether user requested to abort the computation in WL Kernel.
Definition: ProgressMonitor.cpp:33
LLU::ProgressMonitor::operator++
ProgressMonitor & operator++()
Increment current progress value by step.
Definition: ProgressMonitor.cpp:39
LLU::ProgressMonitor::set
void set(double progressValue)
Set current progress value.
Definition: ProgressMonitor.cpp:19
LLU::ProgressMonitor::getDefaultStep
static constexpr double getDefaultStep() noexcept
Return default step for the ProgressMonitor.
Definition: ProgressMonitor.h:107
LLU::ProgressMonitor::operator-=
ProgressMonitor & operator-=(double progress)
Decrement current progress value by a given number.
Definition: ProgressMonitor.cpp:54
LLU::ProgressMonitor::operator=
ProgressMonitor & operator=(const ProgressMonitor &)=delete
Copy-assignment is disabled because ProgressMonitor shares a Tensor with WL Kernel.
Tensor.h
Templated C++ wrapper for MTensor.
LLU::ProgressMonitor
Stores and updates current progress of computation in a location shared between the library and WL Ke...
Definition: ProgressMonitor.h:21
LLU::ProgressMonitor::~ProgressMonitor
~ProgressMonitor()=default
Default destructor.
LLU::ProgressMonitor::get
double get() const
Get current value of the progress.
Definition: ProgressMonitor.cpp:15