]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPR/MULTIPR_ProgressCallback.hxx
Salome HOME
f8e0ff614f8fa9463654025bd80fa8d8090b3456
[modules/multipr.git] / src / MULTIPR / MULTIPR_ProgressCallback.hxx
1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
3
4 /**
5  * \file    MULTIPR_ProgressCallback.hxx
6  *
7  * \brief   Class MULTIPR_ProgressCallback
8  *
9  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
10  * 
11  * \date    01/2007
12  */
13
14 #ifndef MULTIPR_PROGRESS_CALLBACK_HXX
15 #define MULTIPR_PROGRESS_CALLBACK_HXX
16
17 //*****************************************************************************
18 // Includes section
19 //*****************************************************************************
20
21
22 //*****************************************************************************
23 // Class MULTIPR_ProgressCallback
24 // Used to provide feedback on the progress of a slow operation.
25 //*****************************************************************************
26
27 class MULTIPR_ProgressCallback
28 {
29 public:
30         
31         /**
32          * Builds a new MULTIPR_ProgressCallback (default constructor).
33          */
34         MULTIPR_ProgressCallback() { init(100); }
35         
36         /**
37          * Destructor. Removes everything.
38          */
39         ~MULTIPR_ProgressCallback() { /* do nothing */ }
40         
41         /**
42          * Starts to provide feedback on the progress of a slow operation.
43          * \param  pTaskTitle name of the task to be monitored.
44          * \param  pNumSteps  number of steps in the task.
45          */
46         virtual void start(const char* pTaskTitle, int pNumSteps) = 0;
47
48         /**
49          * Moves on the current amount of progress made.
50          */
51         void moveOn() { mCurrentStep++; float percent = float(mCurrentStep)/float(mTotalSteps)*100.0f; progress(percent); }
52         
53         /**
54          * Termines to provide feedback.
55          */
56         virtual void done() = 0;
57         
58 protected:
59         
60         /**
61          * Resets this progress callback.
62          * \param  pNumSteps number of steps in the task to be monitored.
63          */
64         void init(int pNumSteps) { mCurrentStep = 0; mTotalSteps = pNumSteps; }
65         
66         /**
67          * Callback. Called on each progress.
68          * \param  pPercent percent accomplished.
69          */
70         virtual void progress(float pPercent) = 0;
71
72 private:
73
74         int mCurrentStep;
75         int mTotalSteps;
76         
77 }; // class MULTIPR_ProgressCallback
78
79
80 #endif // MULTIPR_PROGRESS_CALLBACK_HXX
81
82 // EOF