cgma
TtyProgressTool.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : TtyProgressTool.hpp
00003 //
00004 // Purpose       : Progress bar for use in text terminals (ttys)
00005 //
00006 // Special Notes : 
00007 //
00008 // Creator       : Jason Kraftcheck
00009 //
00010 // Creation Date : 06/16/03
00011 //-------------------------------------------------------------------------
00012 #ifndef TTY_PROGRESS_TOOL_HPP
00013 #define TTY_PROGRESS_TOOL_HPP
00014 
00015 #include "ProgressTool.hpp"
00016 #include "CGMUtilConfigure.h"
00017 
00018 class CUBIT_UTIL_EXPORT TtyProgressTool : public ProgressTool
00019 {
00020 public:
00021 
00022   inline TtyProgressTool();
00023   virtual ~TtyProgressTool();
00024   
00025   virtual void start( int lower, int upper, 
00026                       const char* title = 0,
00027                       const char* info = 0,
00028                       CubitBoolean smooth = CUBIT_TRUE,
00029                       CubitBoolean cancelButton = CUBIT_FALSE );
00030   
00031   virtual void end();
00032   
00033   virtual void step();
00034   
00035   virtual void percent( double p );
00036   
00037   virtual void check_interrupt();
00038   // callback to allow the progress tool to check for interrupt
00039 
00040   void clear_all();  // clear all object data (inverse of start(..)).
00041   
00042 private:
00043 
00044   bool update();     // check for change in tty width and update if necessary
00045   void display(int step, int pct);    // display progress line
00046 
00047   int myRange;       // number of steps to reach 100% 
00048   int currentVal;    // current step count
00049   int currPercent;   // current percent
00050   int prevWidth;     // result of most recent query for terminal width
00051   
00052   char* lineBuffer;   // buffer holding image of entire line of output
00053   char* barStart;     // start of progress bar (pointer into lineBuffer)
00054   char* bufferEnd;    // one past last buffer character
00055 
00056   char* firstMessage; // copy of first text message passed into start(..)
00057   char* secondMessage;// copy of second text message passed into start(..)
00058 };
00059 
00060 inline TtyProgressTool::TtyProgressTool()
00061   : prevWidth(0), lineBuffer(0), firstMessage(0), secondMessage(0) {}
00062 
00063 #endif
00064 
00065   
00066   
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines