[Compbench-devel] CompBenchmarks++/libcompbenchmarks/UI UI.cpp, 1.3, 1.4 UI.h, 1.2, 1.3
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-05-16 09:47:59
|
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/UI In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv30162 Modified Files: UI.cpp UI.h Log Message: Progress*() methods introduced. Index: UI.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/UI/UI.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UI.h 25 Jan 2007 15:49:07 -0000 1.2 --- UI.h 16 May 2007 09:47:56 -0000 1.3 *************** *** 21,33 **** { private: - protected: - /** Unused for now. */ std::string progressMsg; ! /** Unused for now. */ ! int progressMax; ! /** Unused for now. */ ! int progressCur; ! ! public: UI(); --- 21,27 ---- { private: std::string progressMsg; ! float progressLast; ! protected: public: UI(); *************** *** 70,79 **** std::string msg); ! /* ! virtual int ProgressInit(std::string& msg, ! int max) = 0; ! virtual int Progress(int step) = 0; ! virtual int ProgressDone(void) = 0; ! */ /** Virtual destructor */ --- 64,70 ---- std::string msg); ! virtual void ProgressInit(std::string msg); ! virtual void Progress(float _p); ! virtual void ProgressDone(void); /** Virtual destructor */ *************** *** 82,85 **** --- 73,77 ---- extern UI *cbmUI; + extern UI *cbmUI_old; } Index: UI.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/UI/UI.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UI.cpp 17 Apr 2007 18:20:34 -0000 1.3 --- UI.cpp 16 May 2007 09:47:56 -0000 1.4 *************** *** 12,25 **** #include <iostream> using namespace CBM; CBM::UI *CBM::cbmUI = 0; UI::UI() { progressMsg=""; ! progressMax=-1; ! progressCur=-1; } --- 12,31 ---- #include <iostream> + #include <stdio.h> using namespace CBM; CBM::UI *CBM::cbmUI = 0; + CBM::UI *CBM::cbmUI_old = 0; UI::UI() { + if (cbmUI) + cbmUI_old=cbmUI; + + cbmUI=this; + progressMsg=""; ! progressLast=0; } *************** *** 104,108 **** --- 110,147 ---- } + void UI::ProgressInit(std::string msg) + { + progressMsg=msg; + printf("%s : ", progressMsg.c_str()); + } + + void UI::Progress(float _p) + { + float n = _p-progressLast; + float np = progressLast; + float i; + + n/=5.0; + + for(i=0; i<n; i+=1.0) { + printf("="); + np+=1.0; + } + progressLast=np; + + fflush(stdout); + } + + void UI::ProgressDone(void) + { + Progress(100.0); + printf(" - done.\n"); + } + UI::~UI() { + if (cbmUI_old) + cbmUI=cbmUI_old; + + cbmUI_old=0; } |