ConsoleSleeper.cpp
Go to the documentation of this file.
1 #include "ProgressExamples.h"
2 
3 // TerraLib
4 #include "../../src/terralib/Defines.h"
7 
8 // System
9 #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
10  #include <windows.h>
11 #endif
12 
13 #include <iostream>
14 
15 #define TOTAL_STEPS 2000
16 #define TOTAL_STEPS_INTERNAL 1000
17 
19 {
21 
23  task.setMessage("Console Progress Test");
24 
25  for(unsigned int i = 0; i < TOTAL_STEPS; ++i)
26  {
27  if(i == TOTAL_STEPS_INTERNAL)
28  {
29  te::common::TaskProgress taskInteral;
30 
32  taskInteral.setMessage("Second Task");
33 
34  for(unsigned int j = 0; j < TOTAL_STEPS_INTERNAL; ++j)
35  {
36  if(!taskInteral.isActive())
37  {
38  break;
39  }
40 
41  #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
42  Sleep(5);
43  #endif
44 
45  taskInteral.pulse();
46  }
47  }
48 
49  if(!task.isActive())
50  {
51  break;
52  }
53 
54  #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
55  Sleep(5);
56  #endif
57 
58  task.pulse();
59  }
60 }
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...
void setMessage(const std::string &message)
Set the task message.
This class can be used to inform the progress of a task.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
These routines show how to use the progress bar.
void ConsoleSleeper()
bool isActive() const
Verify if the task is active.
void setTotalSteps(int value)
Set the task total stepes.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
#define TOTAL_STEPS
#define TOTAL_STEPS_INTERNAL