ConsoleProgressViewer.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/ConsoleProgressViewer.h
22 
23  \brief A progress viewer implementation for the console.
24 */
25 
26 #ifndef __TERRALIB_COMMON_PROGRESS_INTERNAL_CONSOLEPROGRESSVIEWER_H
27 #define __TERRALIB_COMMON_PROGRESS_INTERNAL_CONSOLEPROGRESSVIEWER_H
28 
29 // TerraLib
30 #include "../Config.h"
31 #include "AbstractProgressViewer.h"
32 
33 // STL
34 #include <map>
35 #include <string>
36 
37 namespace te
38 {
39  namespace common
40  {
41 // Forward declarations
42  class TaskProgress;
43 
44  /*!
45  \class ConsoleProgressViewer
46 
47  \briefA progress viewer implementation for the console.
48 
49  This viewer is based on iostream. All the feedback will be generated
50  over a console window. Multiples tasks will be displayed using a single
51  report.
52 
53  The proportional value is calculated using TOTAL_STEPS / CURRENT_STEPS. Where:
54  <ul>
55  <li>TOTAL_STEPS: Sum of all total steps of all tasks</li>
56  <li>CURRENTSTEPS: Sum of all current steps of all tasks</li>
57  </ul>
58 
59  The progress message is defined by the task message, if it has more than
60  one task the message will be set to: "MULTI TASKS".
61 
62  \sa AbstractProgressViewer, TaskProgress
63  */
65  {
66  public:
67 
68  /*! \brief Default constructor. */
70 
71  /*! \brief Virtual destructor. */
73 
74  void addTask(TaskProgress* t, int id);
75 
76  void removeTask(int taskId);
77 
78  void cancelTask(int taskId);
79 
80  void setTotalValues(int taskId);
81 
82  void updateValue(int taskId);
83 
84  void updateMessage(int taskId);
85 
86  protected:
87 
88  int m_totalSteps; //!< Attribute used to define the total steps of all tasks.
89  int m_currentStep; //!< Attribute used to define the current steps of all task.
90  int m_propStep; //!< Attribute used to define the proportional step (0-100).
91  std::string m_message; //!< Attribute used to define the progress message.
92  std::map<int, TaskProgress*> m_tasks; //!< Task container.
93  };
94 
95  } // end namespace common
96 } // end namespace te
97 
98 #endif //__TERRALIB_COMMON_PROGRESS_INTERNAL_CONSOLEPROGRESSVIEWER_H
99 
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
int m_currentStep
Attribute used to define the current steps of all task.
std::string m_message
Attribute used to define the progress message.
A class that defines the interface of an abstract progress viewer.
URI C++ Library.
A class that defines the interface of an abstract progress viewer.
#define TECOMMONEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:65
std::map< int, TaskProgress * > m_tasks
Task container.
int m_propStep
Attribute used to define the proportional step (0-100).
int m_totalSteps
Attribute used to define the total steps of all tasks.