Loading...
Searching...
No Matches
TaskProgress.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/TaskProgress.h
22
23 \brief This class can be used to inform the progress of a task.
24*/
25
26#ifndef __TERRALIB_COMMON_PROGRESS_INTERNAL_TASKPROGRESS_H
27#define __TERRALIB_COMMON_PROGRESS_INTERNAL_TASKPROGRESS_H
28
29// TerraLib
30#include "../Config.h"
31
32// STL
33#include <string>
34
35namespace te
36{
37 namespace common
38 {
39// Forward declaration
40 class ProgressTimer;
41
42 /*!
43 \class TaskProgress
44
45 \brief This class can be used to inform the progress of a task.
46
47 \ingroup common
48
49 \sa ProgressTimer, ProgressManager
50
51 \todo ProgressTimer is NOT working if TaskProgress is in multithread mode.
52 */
54 {
55 public:
56
57 /*! \brief Defines some task types. */
58 enum
59 {
60 UNDEFINED = 0, /*!< Undefined task type. */
61 DRAW = 1 /*!< Draw task type. */
62 };
63
64 /*!
65 \brief Default constructor.
66
67 The constructor will register the task in the progress manager.
68 */
69 TaskProgress(const std::string& message = "", unsigned int type = UNDEFINED, int totalSteps = 0);
70
71 /*!
72 \brief Destructor.
73
74 The destructor will remove the task from the progress manager.
75 */
77
78 /*!
79 \brief Get the task identification.
80
81 \return Task id as integer value.
82 */
83 int getId() const;
84
85 /*!
86 \brief Get the task type.
87
88 \return The task type.
89 */
90 unsigned int getType() const;
91
92 /*!
93 \brief Get the task total stepes.
94
95 \return Integer value with total steps.
96 */
97 int getTotalSteps() const;
98
99 /*!
100 \brief Set the task total stepes.
101
102 \param value Interger value with total steps.
103 */
104 void setTotalSteps(int value);
105
106 /*!
107 \brief Get the proportional value (value between 0 and 100).
108
109 \return Proportional value as integer.
110 */
112
113 /*!
114 \brief Get the task current step.
115
116 \return Current step as integer value.
117 */
118 int getCurrentStep() const;
119
120 /*!
121 \brief Set the task current step.
122
123 \param value Current value.
124 */
125 void setCurrentStep(int value);
126
127 /*! \brief Calls setCurrentStep() function using getCurrentStep() + 1. */
128 void pulse();
129
130 /*!
131 \brief Get the task message.
132
133 \return String value with task message.
134 */
135 const std::string& getMessage() const;
136
137 /*!
138 \brief Set the task message.
139
140 \param message String value with task message.
141 */
142 void setMessage(const std::string& message);
143
144 /*!
145 \brief Verify if the task is active.
146
147 \return True if task is active and false in other case.
148 */
149 bool isActive() const;
150
151 /*! \brief Cancel task, set the task active FALSE. */
152 void cancel();
153
154 /*!
155 \brief Used to define if task is running in thread mode.
156
157 \param flag Boolean value used to set the thread option.
158 */
159 void useMultiThread(bool flag);
160
161 /*!
162 \brief Used to define if task use progress timer information.
163
164 \param flag Boolean value used to set the timer option.
165 */
166 void useTimer(bool flag);
167
168 /*!
169 \brief This function is used when proportional value has changed.
170
171 \return True if progress has to be update and false in other case.
172 */
173 bool hasToUpdate() const;
174
175 protected:
176
177 int m_id; //!< Task identification.
178 unsigned int m_type; //!< Task type.
179 int m_totalSteps; //!< Task total steps.
180 int m_currentStep; //!< Task current step.
181 int m_currentPropStep; //!< Current proportinal step.
182 std::string m_message; //!< Task message.
183 bool m_hasToUpdate; //!< Flag used to indicate the update status.
184 bool m_isActive; //!< Flag used to indicate the task status.
185 bool m_isMultiThread; //!< Flag used to indicate the thread mode.
186 bool m_useTimer; //!< Flag used to indicate the timer status.
187 ProgressTimer* m_timer; //!< Progress timer instance.
188 };
189
190 } // end namespace common
191} // end namespace te
192
193#endif //__TERRALIB_COMMON_PROGRESS_INTERNAL_TASKPROGRESS_H
The ProgressTimer is a utility class that can be used to calculate the estimated time to finish a tas...
Definition: ProgressTimer.h:48
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:54
bool m_useTimer
Flag used to indicate the timer status.
Definition: TaskProgress.h:186
int m_currentStep
Task current step.
Definition: TaskProgress.h:180
bool m_hasToUpdate
Flag used to indicate the update status.
Definition: TaskProgress.h:183
void setTotalSteps(int value)
Set the task total stepes.
int getCurrentStep() const
Get the task current step.
ProgressTimer * m_timer
Progress timer instance.
Definition: TaskProgress.h:187
unsigned int m_type
Task type.
Definition: TaskProgress.h:178
unsigned int getType() const
Get the task type.
int getTotalSteps() const
Get the task total stepes.
TaskProgress(const std::string &message="", unsigned int type=UNDEFINED, int totalSteps=0)
Default constructor.
bool m_isMultiThread
Flag used to indicate the thread mode.
Definition: TaskProgress.h:185
void useTimer(bool flag)
Used to define if task use progress timer information.
bool m_isActive
Flag used to indicate the task status.
Definition: TaskProgress.h:184
void setCurrentStep(int value)
Set the task current step.
void setMessage(const std::string &message)
Set the task message.
int m_currentPropStep
Current proportinal step.
Definition: TaskProgress.h:181
int getId() const
Get the task identification.
std::string m_message
Task message.
Definition: TaskProgress.h:182
int getProportionalValue() const
Get the proportional value (value between 0 and 100).
bool isActive() const
Verify if the task is active.
bool hasToUpdate() const
This function is used when proportional value has changed.
const std::string & getMessage() const
Get the task message.
int m_id
Task identification.
Definition: TaskProgress.h:177
void cancel()
Cancel task, set the task active FALSE.
int m_totalSteps
Task total steps.
Definition: TaskProgress.h:179
void useMultiThread(bool flag)
Used to define if task is running in thread mode.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
~TaskProgress()
Destructor.
TerraLib.
#define TECOMMONEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:66