]> git.saurik.com Git - apt.git/blame - apt-pkg/contrib/progress.h
__deprecated is already defined by sys/cdefs.h :/.
[apt.git] / apt-pkg / contrib / progress.h
CommitLineData
404ec98e
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
233b185f 3// $Id: progress.h,v 1.6 2001/05/07 05:06:52 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
1e3f4083 10 the complex case of the multi-activity acquire class.
404ec98e
AL
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
404ec98e
AL
24
25#include <string>
26#include <sys/time.h>
3b302846 27#include <apt-pkg/macros.h>
404ec98e 28
a4f6bdc8
DK
29#ifndef APT_8_CLEANER_HEADERS
30using std::string;
31#endif
32
0a8e3465 33class Configuration;
404ec98e
AL
34class OpProgress
35{
650faab0
DK
36 unsigned long long Current;
37 unsigned long long Total;
38 unsigned long long Size;
39 unsigned long long SubTotal;
404ec98e
AL
40 float LastPercent;
41
42 // Change reduction code
43 struct timeval LastTime;
8f3ba4e8
DK
44 std::string LastOp;
45 std::string LastSubOp;
404ec98e
AL
46
47 protected:
48
8f3ba4e8
DK
49 std::string Op;
50 std::string SubOp;
404ec98e
AL
51 float Percent;
52
53 bool MajorChange;
54
55 bool CheckChange(float Interval = 0.7);
56 virtual void Update() {};
57
58 public:
59
650faab0 60 void Progress(unsigned long long Current);
8f3ba4e8 61 void SubProgress(unsigned long long SubTotal, const std::string &Op = "", float const Percent = -1);
650faab0 62 void OverallProgress(unsigned long long Current,unsigned long long Total,
8f3ba4e8 63 unsigned long long Size,const std::string &Op);
1a7c9eba
AL
64 virtual void Done() {};
65
404ec98e
AL
66 OpProgress();
67 virtual ~OpProgress() {};
68};
69
70class OpTextProgress : public OpProgress
71{
72 protected:
8f3ba4e8
DK
73
74 std::string OldOp;
404ec98e 75 bool NoUpdate;
0a8e3465 76 bool NoDisplay;
404ec98e 77 unsigned long LastLen;
3b302846 78 virtual void Update() APT_OVERRIDE;
404ec98e
AL
79 void Write(const char *S);
80
81 public:
82
3b302846 83 virtual void Done() APT_OVERRIDE;
404ec98e 84
0a8e3465
AL
85 OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate),
86 NoDisplay(false), LastLen(0) {};
87 OpTextProgress(Configuration &Config);
404ec98e
AL
88 virtual ~OpTextProgress() {Done();};
89};
90
91#endif