A simple thread-safe progress callback.
More...
#include <lagrange/utils/ProgressCallback.h>
|
| ProgressCallback (std::function< void(const std::string &, float)> func=nullptr, std::string name="", size_t num_iterations=1) |
| Constructs a new instance. More...
|
|
void | set_callback (std::function< void(const std::string &, float)> func) |
| Set notification callback. More...
|
|
void | set_section (std::string name, size_t num_iterations=1) |
| Starts a new section, reset current iteration counter to 0, and notify. More...
|
|
const std::string & | get_section () const |
| Retrieves current section name. More...
|
|
void | set_num_iterations (size_t num_iterations) |
| Sets the number iterations for this section. More...
|
|
void | advance (size_t increment) |
| Updates the current iteration number by a fixed amount, and sends a notification. More...
|
|
void | update () |
| Updates the current iteration number by one, and sends a notification. More...
|
|
void | update (float progress) |
| Updates the current progress to a fixed percentage. More...
|
|
void | set_verbose (bool verbose) |
| Sets the verbosity. More...
|
|
A simple thread-safe progress callback.
◆ ProgressCallback()
ProgressCallback |
( |
std::function< void(const std::string &, float)> |
func = nullptr , |
|
|
std::string |
name = "" , |
|
|
size_t |
num_iterations = 1 |
|
) |
| |
Constructs a new instance.
- Parameters
-
[in] | func | Notification callback. This callback function will be called in a thread-safe manner by the update() method. |
[in] | name | Default section name. |
[in] | num_iterations | Number of iterations for this section. |
◆ set_callback()
void set_callback |
( |
std::function< void(const std::string &, float)> |
func | ) |
|
Set notification callback.
- Parameters
-
[in] | func | Notification callback. This callback function will be called in a thread-safe manner by the update() method. |
◆ set_section()
void set_section |
( |
std::string |
name, |
|
|
size_t |
num_iterations = 1 |
|
) |
| |
Starts a new section, reset current iteration counter to 0, and notify.
This method is not thread-safe.
- Parameters
-
[in] | name | Section name. |
[in] | num_iterations | Number of iterations for this section. |
◆ get_section()
const std::string & get_section |
( |
| ) |
const |
|
inline |
Retrieves current section name.
- Returns
- Name of the current section.
◆ set_num_iterations()
void set_num_iterations |
( |
size_t |
num_iterations | ) |
|
Sets the number iterations for this section.
No notification is sent. This method is not thread-safe.
- Parameters
-
[in] | num_iterations | Number of iterations for this section. |
◆ advance()
void advance |
( |
size_t |
increment | ) |
|
Updates the current iteration number by a fixed amount, and sends a notification.
It is safe to call this method from multiple threads.
◆ update() [1/2]
Updates the current iteration number by one, and sends a notification.
It is safe to call this method from multiple threads.
◆ update() [2/2]
void update |
( |
float |
progress | ) |
|
Updates the current progress to a fixed percentage.
- Parameters
-
[in] | progress | Current progress between 0 and 1. |
◆ set_verbose()
void set_verbose |
( |
bool |
verbose | ) |
|
|
inline |
Sets the verbosity.
A verbose progress callback will print the section name as debug info whenever set_section
is called with a non-empty section name.
- Parameters
-
[in] | verbose | Verbosity level. |
The documentation for this class was generated from the following files: