ProgressTimer.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 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, std::string message);
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  /*! \brief Set the message used by task progress. */
72  void setMessage(std::string message);
73 
74  /*!
75  \brief Function used to get the remaining time to end the process.
76 
77  \return Dobule value, the remaingin time in minutes.
78  */
79  double getRemainingTimeInMin() const;
80 
81  /*!
82  \brief Function used to get the speed time.
83 
84  \return Double value, the spped time in seconds.
85  */
86  double getSpeedTimeInSec() const;
87 
88  /*!
89  \brief Get the information about the evolution of the process.
90 
91  \return String with the information about remaining and speed time.
92  */
93  std::string getMessage();
94 
95  private:
96 
97  int m_totalSteps; //!< Total steps.
98  int m_count; //!< Internal counter.
99  time_t m_startTime; //!< Initial time.
100  double m_remainingTime; //!< Remaining time in minutes.
101  double m_speedTime; //!< Speed time in seconds.
102  std::string m_message; //!< Original task message
103  };
104 
105  } // end namespace common
106 } // end namespace te
107 
108 #endif // __TERRALIB_COMMON_PROGRESS_INTERNAL_PROGRESSTIMER_H
109 
time_t m_startTime
Initial time.
Definition: ProgressTimer.h:99
int m_count
Internal counter.
Definition: ProgressTimer.h:98
double m_speedTime
Speed time in seconds.
std::string m_message
Original task message.
double m_remainingTime
Remaining time in minutes.
URI C++ Library.
#define TECOMMONEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:65
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_totalSteps
Total steps.
Definition: ProgressTimer.h:97