All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProgressTimer.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/common/progress/ProgressTimer.h
22 
23  \brief The ProgressTimer is a utility class that can be used to calculate the estimated time to finish a task.
24 */
25 
26 #ifndef __TERRALIB_COMMON_PROGRESS_INTERNAL_PROGRESSTIMER_H
27 #define __TERRALIB_COMMON_PROGRESS_INTERNAL_PROGRESSTIMER_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // STL
33 #include <ctime>
34 #include <string>
35 
36 namespace te
37 {
38  namespace common
39  {
40  /*!
41  \class ProgressTimer
42 
43  \brief The ProgressTimer is a utility class that can be used to calculate the estimated time to finish a task.
44 
45  \sa TaskProgress
46  */
48  {
49 
50  public:
51 
52  /*! \brief It initializes a ProgressTimer. */
53  ProgressTimer(int totalSteps);
54 
55  /*! \brief Destructor. */
56  ~ProgressTimer();
57 
58  /*! \brief Start the internal timer. */
59  void start();
60 
61  /*!
62  \brief Define a new step process evolution.
63 
64  \note For each tick, new values for remaining time and speed time are computed.
65  */
66  void tick();
67 
68  /*! \brief Set the total steps. */
69  void setTotalSteps(int totalSteps);
70 
71  /*!
72  \brief Function used to get the remaining time to end the process.
73 
74  \return Dobule value, the remaingin time in minutes.
75  */
76  double getRemainingTimeInMin() const;
77 
78  /*!
79  \brief Function used to get the speed time.
80 
81  \return Double value, the spped time in seconds.
82  */
83  double getSpeedTimeInSec() const;
84 
85  /*!
86  \brief Get the information about the evolution of the process.
87 
88  \return String with the information about remaining and speed time.
89  */
90  std::string getMessage();
91 
92  private:
93 
94  int m_totalSteps; //!< Total steps.
95  int m_count; //!< Internal counter.
96  time_t m_startTime; //!< Initial time.
97  double m_remainingTime; //!< Remaining time in minutes.
98  double m_speedTime; //!< Speed time in seconds.
99  };
100 
101  } // end namespace common
102 } // end namespace te
103 
104 #endif // __TERRALIB_COMMON_PROGRESS_INTERNAL_PROGRESSTIMER_H
105 
int m_totalSteps
Total steps.
Definition: ProgressTimer.h:94
#define TECOMMONEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:455
time_t m_startTime
Initial time.
Definition: ProgressTimer.h:96
double m_remainingTime
Remaining time in minutes.
Definition: ProgressTimer.h:97
The ProgressTimer is a utility class that can be used to calculate the estimated time to finish a tas...
Definition: ProgressTimer.h:47
int m_count
Internal counter.
Definition: ProgressTimer.h:95
double m_speedTime
Speed time in seconds.
Definition: ProgressTimer.h:98