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