2022-03-01 17:17:15 +01:00
|
|
|
#ifndef MISSION_UTILITY_PROGRESSPRINTER_H_
|
|
|
|
#define MISSION_UTILITY_PROGRESSPRINTER_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Class which can be used to print the progress of processes in percent.
|
|
|
|
*
|
|
|
|
* @author J. Meier
|
|
|
|
*/
|
|
|
|
class ProgressPrinter {
|
|
|
|
public:
|
2022-04-25 11:03:02 +02:00
|
|
|
static constexpr float HALF_PERCENT = 0.5;
|
|
|
|
static constexpr float ONE_PERCENT = 1;
|
|
|
|
static constexpr float FIVE_PERCENT = 5;
|
2022-04-16 17:19:32 +02:00
|
|
|
|
2022-03-01 17:17:15 +01:00
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*
|
2022-04-16 17:19:32 +02:00
|
|
|
* @param name Name of the process to monitor
|
|
|
|
* @param numSteps Number of steps to execute
|
|
|
|
* @param percentageResolution Distance between printed percentage steps. E.g. 5 means that
|
|
|
|
* a printout will be generated after 0%, 5%, 10% etc.
|
2022-03-01 17:17:15 +01:00
|
|
|
*/
|
2022-04-25 11:03:02 +02:00
|
|
|
ProgressPrinter(std::string name, uint32_t numSteps, float percentageResolution = FIVE_PERCENT);
|
2022-03-01 17:17:15 +01:00
|
|
|
virtual ~ProgressPrinter();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Will print the progress
|
|
|
|
*
|
|
|
|
* @param currentStep Current step from which to derive progress
|
|
|
|
*/
|
|
|
|
void print(uint32_t step);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name = "";
|
|
|
|
uint32_t numSteps = 0;
|
2022-04-25 11:03:02 +02:00
|
|
|
float nextProgressPrint = 0;
|
|
|
|
float percentageResolution = 0;
|
2022-03-01 17:17:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_UTILITY_PROGRESSPRINTER_H_ */
|