~ubuntu-branches/ubuntu/hardy/libterralib/hardy

« back to all changes in this revision

Viewing changes to src/terralib/kernel/TeStdIOProgress.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-25 22:32:59 UTC
  • Revision ID: james.westby@ubuntu.com-20051125223259-3zubal8ux4ki4fjg
Tags: upstream-3.0.3b2
ImportĀ upstreamĀ versionĀ 3.0.3b2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef TeSTDIOPROGRESS_H
 
2
#define TeSTDIOPROGRESS_H
 
3
 
 
4
#include "TeProgressBase.h"
 
5
#include <iostream>
 
6
 
 
7
class TeStdIOProgress : public TeProgressBase
 
8
{
 
9
public:
 
10
 
 
11
        //! Constructor
 
12
        TeStdIOProgress() :
 
13
                totsteps(0),
 
14
                nsteps(0),
 
15
                curstep(-1)
 
16
        {}
 
17
 
 
18
        //! Destructor
 
19
        ~TeStdIOProgress() {}
 
20
 
 
21
        //! Sets the total number of steps to n 
 
22
        void setTotalSteps(int n) { totsteps = n; }
 
23
 
 
24
        //! Sets the current amount of progress made to n
 
25
        void setProgress(int n) 
 
26
        { 
 
27
                if (totsteps > 0) 
 
28
                {
 
29
                        int aux = (int)((n*100)/totsteps);
 
30
                        if (aux != curstep)
 
31
                        {
 
32
                                curstep = aux;
 
33
                                cout << curstep << "% ";
 
34
                                cout.flush();
 
35
                        }
 
36
                }
 
37
        }
 
38
 
 
39
        //! Resets the progress interface
 
40
        void reset() { totsteps = nsteps = 0; curstep = -1; }
 
41
 
 
42
        //! Resets the progress dialog
 
43
        void cancel() {};
 
44
 
 
45
        //! Sets the label's text
 
46
        void setMessage(const string& text) { cout << endl << text << endl;}
 
47
 
 
48
        //! Returns true whether the process was cancelled
 
49
        bool wasCancelled() { return false; }
 
50
        
 
51
        //! Sets the caption associated to the progress interface
 
52
        void setCaption(const string& /*cap*/) {};
 
53
 
 
54
private:
 
55
        int totsteps;
 
56
        int nsteps;
 
57
        int curstep;
 
58
 
 
59
};
 
60
#endif