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