2021-06-26 15:24:07 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2019-10-05 18:58:52 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef PROGRESSBARE_HPP
|
|
|
|
|
#define PROGRESSBARE_HPP
|
|
|
|
|
#include <iostream>
|
2021-02-24 13:31:55 +01:00
|
|
|
#include <chrono>
|
2019-10-05 18:58:52 +02:00
|
|
|
|
|
|
|
|
class ProgressBar {
|
|
|
|
|
public:
|
2021-01-30 07:57:49 +01:00
|
|
|
ProgressBar(std::string mess, int maxValue, int progressLen,
|
|
|
|
|
bool quiet = false);
|
2020-12-24 23:35:05 +01:00
|
|
|
void display(int value, char force = 0);
|
2019-10-05 18:58:52 +02:00
|
|
|
void done();
|
2019-11-20 07:51:37 +01:00
|
|
|
void fail();
|
2019-10-05 18:58:52 +02:00
|
|
|
private:
|
|
|
|
|
std::string _mess;
|
|
|
|
|
int _maxValue;
|
|
|
|
|
int _progressLen;
|
2021-02-24 13:31:55 +01:00
|
|
|
//records the time of last progress bar update
|
|
|
|
|
std::chrono::time_point<std::chrono::system_clock> last_time;
|
2021-01-30 07:57:49 +01:00
|
|
|
bool _quiet;
|
|
|
|
|
bool _first;
|
2019-10-05 18:58:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|