00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PKGLIB_PROGRESS_H
00022 #define PKGLIB_PROGRESS_H
00023
00024
00025 #include <string>
00026 #include <sys/time.h>
00027
00028 using std::string;
00029
00030 class Configuration;
00031 class OpProgress
00032 {
00033 unsigned long Current;
00034 unsigned long Total;
00035 unsigned long Size;
00036 unsigned long SubTotal;
00037 float LastPercent;
00038
00039
00040 struct timeval LastTime;
00041 string LastOp;
00042 string LastSubOp;
00043
00044 protected:
00045
00046 string Op;
00047 string SubOp;
00048 float Percent;
00049
00050 bool MajorChange;
00051
00052 bool CheckChange(float Interval = 0.7);
00053 virtual void Update() {};
00054
00055 public:
00056
00057 void Progress(unsigned long Current);
00058 void SubProgress(unsigned long SubTotal);
00059 void SubProgress(unsigned long SubTotal,const string &Op);
00060 void OverallProgress(unsigned long Current,unsigned long Total,
00061 unsigned long Size,const string &Op);
00062 virtual void Done() {};
00063
00064 OpProgress();
00065 virtual ~OpProgress() {};
00066 };
00067
00068 class OpTextProgress : public OpProgress
00069 {
00070 protected:
00071
00072 string OldOp;
00073 bool NoUpdate;
00074 bool NoDisplay;
00075 unsigned long LastLen;
00076 virtual void Update();
00077 void Write(const char *S);
00078
00079 public:
00080
00081 virtual void Done();
00082
00083 OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate),
00084 NoDisplay(false), LastLen(0) {};
00085 OpTextProgress(Configuration &Config);
00086 virtual ~OpTextProgress() {Done();};
00087 };
00088
00089 #endif