blob: f884d62feaf35059242c5bdd1568923fa8288c2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#pragma once
#include <cstdint>
namespace host_tool
{
class ProgressInterface
{
public:
virtual ~ProgressInterface() = default;
/** Update the progress by X bytes. This will inform any listening
* interfaces (just write to stdout mostly), and tick off as time passed.
*/
virtual void updateProgress(std::int64_t bytes) = 0;
virtual void start(std::int64_t bytes) = 0;
};
/**
* @brief A progress indicator that writes to stdout. It deliberately
* overwrites the same line when it's used, so it's advised to not interject
* other non-error messages.
*/
class ProgressStdoutIndicator : public ProgressInterface
{
public:
ProgressStdoutIndicator() = default;
void updateProgress(std::int64_t bytes) override;
void start(std::int64_t bytes) override;
private:
std::int64_t totalBytes = 0;
std::int64_t currentBytes = 0;
};
} // namespace host_tool
|