apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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