1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//-------------------------------------------------------------------------
// Filename      : TtyProgressTool.hpp
//
// Purpose       : Progress bar for use in text terminals (ttys)
//
// Special Notes : 
//
// Creator       : Jason Kraftcheck
//
// Creation Date : 06/16/03
//-------------------------------------------------------------------------
#ifndef TTY_PROGRESS_TOOL_HPP
#define TTY_PROGRESS_TOOL_HPP

#include "ProgressTool.hpp"
#include "CubitUtilConfigure.h"

class CUBIT_UTIL_EXPORT TtyProgressTool : public ProgressTool
{
public:

  inline TtyProgressTool();
  virtual ~TtyProgressTool();
  
  virtual void start( int lower, int upper, 
                      const char* title = 0,
                      const char* info = 0,
                      CubitBoolean smooth = CUBIT_TRUE,
                      CubitBoolean cancelButton = CUBIT_FALSE );
  
  virtual void end();
  
  virtual void step();
  
  virtual void percent( double p );
  
  virtual void check_interrupt();
  // callback to allow the progress tool to check for interrupt

  void clear_all();  // clear all object data (inverse of start(..)).
  
private:

  bool update();     // check for change in tty width and update if necessary
  void display(int step, int pct);    // display progress line

  int myRange;       // number of steps to reach 100% 
  int currentVal;    // current step count
  int currPercent;   // current percent
  int prevWidth;     // result of most recent query for terminal width
  
  char* lineBuffer;   // buffer holding image of entire line of output
  char* barStart;     // start of progress bar (pointer into lineBuffer)
  char* bufferEnd;    // one past last buffer character

  char* firstMessage; // copy of first text message passed into start(..)
  char* secondMessage;// copy of second text message passed into start(..)
};

inline TtyProgressTool::TtyProgressTool()<--- Member variable 'TtyProgressTool::myRange' is not initialized in the constructor.<--- Member variable 'TtyProgressTool::currentVal' is not initialized in the constructor.<--- Member variable 'TtyProgressTool::currPercent' is not initialized in the constructor.<--- Member variable 'TtyProgressTool::barStart' is not initialized in the constructor.<--- Member variable 'TtyProgressTool::bufferEnd' is not initialized in the constructor.
  : prevWidth(0), lineBuffer(0), firstMessage(0), secondMessage(0) {}

#endif