eive-obsw/mission/utility/ProgressPrinter.h
Jakob Meier ffd64d0463
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
improvements in supervisor helper
2022-04-19 13:33:37 +02:00

44 lines
1.1 KiB
C++

#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:
static const uint32_t ONE_PERCENT = 1;
/**
* @brief Constructor
*
* @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.
*/
ProgressPrinter(std::string name, uint32_t numSteps, uint32_t percentageResolution = FIVE_PERCENT);
virtual ~ProgressPrinter();
/**
* @brief Will print the progress
*
* @param currentStep Current step from which to derive progress
*/
void print(uint32_t step);
private:
static constexpr uint32_t FIVE_PERCENT = 5;
std::string name = "";
uint32_t numSteps = 0;
uint32_t nextProgressPrint = 0;
uint32_t percentageResolution = 0;
};
#endif /* MISSION_UTILITY_PROGRESSPRINTER_H_ */