[Compbench-devel] CompBenchmarks++/libcompbenchmarks/UI UI.cpp, 1.4, 1.5 UI.h, 1.3, 1.4
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-05-16 12:06:52
|
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/UI In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv17107 Modified Files: UI.cpp UI.h Log Message: Improved UI API. Index: UI.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/UI/UI.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UI.h 16 May 2007 09:47:56 -0000 1.3 --- UI.h 16 May 2007 12:05:57 -0000 1.4 *************** *** 21,25 **** { private: ! std::string progressMsg; float progressLast; protected: --- 21,25 ---- { private: ! std::string msg; float progressLast; protected: *************** *** 28,50 **** /** Typedef for message sent to UI object. */ ! typedef enum Info { FileCreate, /*!< File creation */ ! FileRead, /*!< File is being read */ ! FileWrite, /*!< File has been written */ ! FileRemove, /*!< File has been removed */ ! ChecksumOK, /*!< Correct checksum message */ ! ChecksumFailed, /*!< Bad checksum */ ! DirectoryCreate, /*!< Directory has been created */ ! BenchDownload, /*!< Benchmark downloaded */ ! BenchExtract, /*!< Benchmark extracted */ ! BenchPatch, /*!< Benchmark patched */ ! BenchPreconfigure, /*!< Benchmark pre-configured */ ! BenchConfigure, /*!< Benchmark configured */ ! BenchMake, /*!< Benchmark (package) build */ ! BenchTest, /*!< Benchmark is tested */ ! BenchBench, /*!< Benchmark ran */ ! BenchResult, /*!< Benchmark result is being ! * displayed */ ! BenchClean, /*!< Package has been cleaned */ ! BenchUninstall /*!< Package uninstalled */ }; --- 28,53 ---- /** Typedef for message sent to UI object. */ ! typedef enum Info { FileCreate, /*!< File creation */ ! FileRead, /*!< File is being read */ ! FileWrite, /*!< File has been written */ ! FileRemove, /*!< File has been removed */ ! Checksum, /*!< Checksum related messages */ ! DirectoryCreate, /*!< Directory has been created */ ! PackageDownload, /*!< Package download */ ! PackageExtract, /*!< Package extract */ ! PackagePatch, /*!< Package patching */ ! PackagePreconfigure, /*!< Package pre-configuration */ ! PackageConfigure, /*!< Package configuration */ ! PackageMake, /*!< Package building */ ! PackageTest, /*!< Package testing */ ! BenchBench, /*!< Benchmark ran */ ! BenchResult, /*!< Benchmark result is being ! * displayed */ ! PackageClean, /*!< Package cleaning */ ! PackageUninstall /*!< Package uninstallation */ ! }; ! ! typedef enum State { ! Start, Running, OK, Failed }; *************** *** 61,70 **** \param msg Message (clear text) to display */ virtual int Information(Info type, ! std::string msg); ! virtual void ProgressInit(std::string msg); ! virtual void Progress(float _p); ! virtual void ProgressDone(void); /** Virtual destructor */ --- 64,85 ---- \param msg Message (clear text) to display */ + + virtual std::string LastMessage(void); + virtual float LastProgress(void); + virtual int Information(Info type, ! std::string _msg, ! State state = Start, ! float _progress = 0); ! virtual int Information(Info type, ! State state = Start, ! float _progress = 0); ! ! /* ! virtual void ProgressInit(std::string msg); ! virtual void Progress(float _p); ! virtual void ProgressDone(void); ! */ /** Virtual destructor */ Index: UI.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/UI/UI.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UI.cpp 16 May 2007 09:47:56 -0000 1.4 --- UI.cpp 16 May 2007 12:05:57 -0000 1.5 *************** *** 26,30 **** cbmUI=this; ! progressMsg=""; progressLast=0; } --- 26,30 ---- cbmUI=this; ! msg=""; progressLast=0; } *************** *** 40,45 **** } int UI::Information(CBM::UI::Info type, ! std::string msg) { std::string what; --- 40,58 ---- } + std::string UI::LastMessage(void) + { + return(msg); + } + + float UI::LastProgress(void) + { + return(progressLast); + } + + int UI::Information(CBM::UI::Info type, ! std::string _msg, ! State state, ! float _progress) { std::string what; *************** *** 61,92 **** what="Removing"; break; ! case ChecksumOK: ! what="MD5 Checksum successfuly verified on"; ! break; ! case ChecksumFailed: ! what="Bad MD5 Checksum on"; break; case DirectoryCreate: what="Creating directory"; break; ! case BenchDownload: what="Downloading"; break; ! case BenchExtract: what="Extracting"; break; ! case BenchPatch: what="Patching"; break; ! case BenchPreconfigure: what="Preconfiguring"; break; ! case BenchConfigure: what="Configuring"; break; ! case BenchTest: what="Testing"; break; ! case BenchMake: what="Making"; break; --- 74,102 ---- what="Removing"; break; ! case Checksum: ! what="MD5 Checksum verification"; break; case DirectoryCreate: what="Creating directory"; break; ! case PackageDownload: what="Downloading"; break; ! case PackageExtract: what="Extracting"; break; ! case PackagePatch: what="Patching"; break; ! case PackagePreconfigure: what="Preconfiguring"; break; ! case PackageConfigure: what="Configuring"; break; ! case PackageTest: what="Testing"; break; ! case PackageMake: what="Making"; break; *************** *** 97,104 **** what="Benchmark result :"; break; ! case BenchClean: what="Cleaning"; break; ! case BenchUninstall: what="Uninstalling"; break; --- 107,114 ---- what="Benchmark result :"; break; ! case PackageClean: what="Cleaning"; break; ! case PackageUninstall: what="Uninstalling"; break; *************** *** 106,113 **** what="(?)"; } ! std::cout << what << " " << msg << std::endl; return(1); } void UI::ProgressInit(std::string msg) { --- 116,172 ---- what="(?)"; } ! ! msg=_msg; ! ! if (state==Running) { ! float n = _progress-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); ! } else { ! std::string dum; ! switch(state) { ! case Start: ! dum="Starting"; ! break; ! case Running: ! dum="Running"; ! break; ! case OK: ! dum="OK"; ! break; ! case Failed: ! dum="Failed"; ! break; ! default: ! dum="??? <internal error>"; ! break; ! } ! if (progressLast!=0) { ! std::cout << std::endl; ! progressLast=0; ! } ! std::cout << msg << " " << what << " " << dum << std::endl; ! } return(1); } + int UI::Information(CBM::UI::Info type, + State state, + float _progress) + { + return(Information(type, msg, state, _progress)); + } + + /* void UI::ProgressInit(std::string msg) { *************** *** 118,134 **** 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); } --- 177,181 ---- *************** *** 138,141 **** --- 185,190 ---- printf(" - done.\n"); } + */ + UI::~UI() |