Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MULTIPR / MULTIPR_ProgressCallback.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Partitioning/decimation module for the SALOME v3.2 platform
20 //
21 /**
22  * \file    MULTIPR_ProgressCallback.hxx
23  *
24  * \brief   Class MULTIPR_ProgressCallback
25  *
26  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
27  * 
28  * \date    01/2007
29  */
30
31 #ifndef MULTIPR_PROGRESS_CALLBACK_HXX
32 #define MULTIPR_PROGRESS_CALLBACK_HXX
33
34 //*****************************************************************************
35 // Includes section
36 //*****************************************************************************
37
38
39 //*****************************************************************************
40 // Class MULTIPR_ProgressCallback
41 // Used to provide feedback on the progress of a slow operation.
42 //*****************************************************************************
43
44 class MULTIPR_ProgressCallback
45 {
46 public:
47     
48     /**
49      * Builds a new MULTIPR_ProgressCallback (default constructor).
50      */
51     MULTIPR_ProgressCallback() { init(100); }
52     
53     /**
54      * Destructor. Removes everything.
55      */
56     virtual ~MULTIPR_ProgressCallback() { /* do nothing */ }
57     
58     /**
59      * Starts to provide feedback on the progress of a slow operation.
60      * \param  pTaskTitle name of the task to be monitored.
61      * \param  pNumSteps  number of steps in the task.
62      */
63     virtual void start(const char* pTaskTitle, int pNumSteps) = 0;
64
65     /**
66      * Moves on the current amount of progress made.
67      */
68     void moveOn() { mCurrentStep++; float percent = float(mCurrentStep)/float(mTotalSteps)*100.0f; progress(percent); }
69     
70     /**
71      * Termines to provide feedback.
72      */
73     virtual void done() = 0;
74     
75 protected:
76     
77     /**
78      * Resets this progress callback.
79      * \param  pNumSteps number of steps in the task to be monitored.
80      */
81     void init(int pNumSteps) { mCurrentStep = 0; mTotalSteps = pNumSteps; }
82     
83     /**
84      * Callback. Called on each progress.
85      * \param  pPercent percent accomplished.
86      */
87     virtual void progress(float pPercent) = 0;
88
89 private:
90
91     int mCurrentStep;
92     int mTotalSteps;
93     
94 }; // class MULTIPR_ProgressCallback
95
96
97 //*****************************************************************************
98 // Class MULTIPR_EmptyMeshCallback
99 // Used to provide feedback when an empty mesh is produced.
100 //*****************************************************************************
101
102 class MULTIPR_EmptyMeshCallback
103 {
104 public:
105     
106     /**
107      * Builds a new MULTIPR_EmptyMeshCallback (default constructor).
108      */
109     MULTIPR_EmptyMeshCallback() { /* do nothing */ }
110     
111     /**
112      * Destructor. Removes everything.
113      */
114     virtual ~MULTIPR_EmptyMeshCallback() { /* do nothing */ }
115
116     /**
117      * Callback. Called each time an empty mesh is produced.
118      * \param  pInfo information related to the empty mesh.
119      */
120     virtual void reportEmptyMesh(std::string pInfo) = 0;
121     
122 }; // class MULTIPR_EmptyMeshCallback
123
124
125 #endif // MULTIPR_PROGRESS_CALLBACK_HXX
126
127 // EOF