]> git.saurik.com Git - apt.git/blame - apt-pkg/contrib/progress.h
CDROM method
[apt.git] / apt-pkg / contrib / progress.h
CommitLineData
404ec98e
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
0a8e3465 3// $Id: progress.h,v 1.4 1998/10/02 04:39:54 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 /*}}}*/
21// Header section: pkglib
22#ifndef PKGLIB_PROGRESS_H
23#define PKGLIB_PROGRESS_H
24
25#ifdef __GNUG__
26#pragma interface "apt-pkg/progress.h"
27#endif
28
29#include <string>
30#include <sys/time.h>
31
0a8e3465 32class Configuration;
404ec98e
AL
33class OpProgress
34{
35 unsigned long Current;
36 unsigned long Total;
37 unsigned long Size;
38 unsigned long SubTotal;
39 float LastPercent;
40
41 // Change reduction code
42 struct timeval LastTime;
43 string LastOp;
1a7c9eba 44 string LastSubOp;
404ec98e
AL
45
46 protected:
47
48 string Op;
49 string SubOp;
50 float Percent;
51
52 bool MajorChange;
53
54 bool CheckChange(float Interval = 0.7);
55 virtual void Update() {};
56
57 public:
58
59 void Progress(unsigned long Current);
8ce4327b 60 void SubProgress(unsigned long SubTotal);
404ec98e
AL
61 void SubProgress(unsigned long SubTotal,string Op);
62 void OverallProgress(unsigned long Current,unsigned long Total,
63 unsigned long Size,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:
73
74 string OldOp;
75 bool NoUpdate;
0a8e3465 76 bool NoDisplay;
404ec98e
AL
77 unsigned long LastLen;
78 virtual void Update();
79 void Write(const char *S);
80
81 public:
82
1a7c9eba 83 virtual void Done();
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