]>
Commit | Line | Data |
---|---|---|
404ec98e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
7f25bdff | 3 | // $Id: progress.h,v 1.5 1999/01/18 06:20:08 jgg Exp $ |
404ec98e AL |
4 | /* ###################################################################### |
5 | ||
6 | OpProgress - Operation Progress | |
7 | ||
8 | This class allows lengthy operations to communicate their progress | |
9 | to the GUI. The progress model is simple and is not designed to handle | |
10 | the complex case of the multi-activity aquire class. | |
11 | ||
12 | The model is based on the concept of an overall operation consisting | |
13 | of a series of small sub operations. Each sub operation has it's own | |
14 | completion status and the overall operation has it's completion status. | |
15 | The units of the two are not mixed and are completely independent. | |
16 | ||
17 | The UI is expected to subclass this to provide the visuals to the user. | |
18 | ||
19 | ##################################################################### */ | |
20 | /*}}}*/ | |
404ec98e AL |
21 | #ifndef PKGLIB_PROGRESS_H |
22 | #define PKGLIB_PROGRESS_H | |
23 | ||
24 | #ifdef __GNUG__ | |
25 | #pragma interface "apt-pkg/progress.h" | |
26 | #endif | |
27 | ||
28 | #include <string> | |
29 | #include <sys/time.h> | |
30 | ||
0a8e3465 | 31 | class Configuration; |
404ec98e AL |
32 | class OpProgress |
33 | { | |
34 | unsigned long Current; | |
35 | unsigned long Total; | |
36 | unsigned long Size; | |
37 | unsigned long SubTotal; | |
38 | float LastPercent; | |
39 | ||
40 | // Change reduction code | |
41 | struct timeval LastTime; | |
42 | string LastOp; | |
1a7c9eba | 43 | string LastSubOp; |
404ec98e AL |
44 | |
45 | protected: | |
46 | ||
47 | string Op; | |
48 | string SubOp; | |
49 | float Percent; | |
50 | ||
51 | bool MajorChange; | |
52 | ||
53 | bool CheckChange(float Interval = 0.7); | |
54 | virtual void Update() {}; | |
55 | ||
56 | public: | |
57 | ||
58 | void Progress(unsigned long Current); | |
8ce4327b | 59 | void SubProgress(unsigned long SubTotal); |
404ec98e AL |
60 | void SubProgress(unsigned long SubTotal,string Op); |
61 | void OverallProgress(unsigned long Current,unsigned long Total, | |
62 | unsigned long Size,string Op); | |
1a7c9eba AL |
63 | virtual void Done() {}; |
64 | ||
404ec98e AL |
65 | OpProgress(); |
66 | virtual ~OpProgress() {}; | |
67 | }; | |
68 | ||
69 | class OpTextProgress : public OpProgress | |
70 | { | |
71 | protected: | |
72 | ||
73 | string OldOp; | |
74 | bool NoUpdate; | |
0a8e3465 | 75 | bool NoDisplay; |
404ec98e AL |
76 | unsigned long LastLen; |
77 | virtual void Update(); | |
78 | void Write(const char *S); | |
79 | ||
80 | public: | |
81 | ||
1a7c9eba | 82 | virtual void Done(); |
404ec98e | 83 | |
0a8e3465 AL |
84 | OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate), |
85 | NoDisplay(false), LastLen(0) {}; | |
86 | OpTextProgress(Configuration &Config); | |
404ec98e AL |
87 | virtual ~OpTextProgress() {Done();}; |
88 | }; | |
89 | ||
90 | #endif |