diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:07:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:07:13 +0000 |
commit | 636c7dc17286d93d788c741d15fd756aeda066d5 (patch) | |
tree | e7ae158cc54f591041a061b9865bcae51854f15c /apt-pkg/contrib/progress.h | |
parent | Initial commit. (diff) | |
download | apt-a2079028732f30f4b85b1e599887c566466d695d.tar.xz apt-a2079028732f30f4b85b1e599887c566466d695d.zip |
Adding upstream version 1.8.2.3.upstream/1.8.2.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'apt-pkg/contrib/progress.h')
-rw-r--r-- | apt-pkg/contrib/progress.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h new file mode 100644 index 0000000..4406a38 --- /dev/null +++ b/apt-pkg/contrib/progress.h @@ -0,0 +1,89 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + OpProgress - Operation Progress + + This class allows lengthy operations to communicate their progress + to the GUI. The progress model is simple and is not designed to handle + the complex case of the multi-activity acquire class. + + The model is based on the concept of an overall operation consisting + of a series of small sub operations. Each sub operation has it's own + completion status and the overall operation has it's completion status. + The units of the two are not mixed and are completely independent. + + The UI is expected to subclass this to provide the visuals to the user. + + ##################################################################### */ + /*}}}*/ +#ifndef PKGLIB_PROGRESS_H +#define PKGLIB_PROGRESS_H + +#include <apt-pkg/macros.h> +#include <string> +#include <sys/time.h> + +#ifndef APT_8_CLEANER_HEADERS +using std::string; +#endif + +class Configuration; +class OpProgress +{ + unsigned long long Current; + unsigned long long Total; + unsigned long long Size; + unsigned long long SubTotal; + float LastPercent; + + // Change reduction code + struct timeval LastTime; + std::string LastOp; + std::string LastSubOp; + + protected: + + std::string Op; + std::string SubOp; + float Percent; + + bool MajorChange; + + bool CheckChange(float Interval = 0.7); + virtual void Update() {}; + + public: + + void Progress(unsigned long long Current); + void SubProgress(unsigned long long SubTotal, const std::string &Op = "", float const Percent = -1); + void OverallProgress(unsigned long long Current,unsigned long long Total, + unsigned long long Size,const std::string &Op); + virtual void Done() {}; + + OpProgress(); + virtual ~OpProgress() {}; +}; + +class OpTextProgress : public OpProgress +{ + protected: + + std::string OldOp; + bool NoUpdate; + bool NoDisplay; + unsigned long LastLen; + virtual void Update() APT_OVERRIDE; + void Write(const char *S); + + public: + + virtual void Done() APT_OVERRIDE; + + OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate), + NoDisplay(false), LastLen(0) {}; + OpTextProgress(Configuration &Config); + virtual ~OpTextProgress() {Done();}; +}; + +#endif |