00001
00002
00003
00004
00005
00006 #ifndef __Output__Class__
00007 #define __Output__Class__
00008 #include <iostream>
00009 #include <fstream>
00010 #include <sstream>
00011 #include <vector>
00012 #include <string>
00013 #include <stdio.h>
00014 #include <boost/timer.hpp>
00015 #include <boost/shared_ptr.hpp>
00016
00017
00018 #undef PACKAGE
00019
00020 namespace phaser_io {
00021
00022 enum package {
00023 NO_PACKAGE,PACKAGE_PHENIX,PACKAGE_CCP4,PACKAGE_CIMR
00024 };
00025
00026 enum outStream {
00027 SUMMARY, LOGFILE, VERBOSE, DEBUG, LXML, RESULT};
00028
00029
00030 class Output
00031 {
00032 public:
00033 Output();
00034 void setOutput(const Output &);
00035 Output(const Output &);
00036 const Output& operator=(const Output&);
00037 virtual ~Output() throw() { WriteResult(); verboseStream.close(); logfileStream.close();
00038 summaryStream.close(); xmlStream.close(); }
00039
00040 private:
00041 package PACKAGE;
00042 bool TOG_CCP4_SUMMARY,VERBOSE_ON,DEBUG_ON,XMLOUT,SILENT;
00043 std::string FILEROOT,XMLFILE;
00044 std::ofstream verboseStream,logfileStream,summaryStream,xmlStream;
00045 std::string verboseString,logfileString,summaryString,resultString;
00046 int jumpnum,progressCount,progressBars,progressBarSize,progressChunk;
00047 std::clock_t start_clock;
00048 double run_time,elapsed_time;
00049 int max_line_width;
00050
00051 protected:
00052
00053
00054 private:
00055 void logOutput(outStream,const std::string&);
00056 std::string formatMessage(const std::string,int,bool,bool=false);
00057 std::string tab(int);
00058 std::string getLine(unsigned,char);
00059 int Days(double);
00060 int Hrs(double);
00061 int Mins(double);
00062 double Secs(double);
00063 void IncrementRunTime();
00064
00065 public:
00066 void openOutputStreams(std::string);
00067 void startClock();
00068
00069 void logHeader(outStream);
00070 void logSectionHeader(outStream,std::string);
00071
00072 void logBlank(outStream);
00073 void logFlush();
00074 void logUnderLine(outStream,const std::string);
00075 void logKeywords(outStream,const std::string);
00076 void logTab(unsigned,outStream,const std::string,bool add_return=true);
00077 void logTabPrintf(unsigned,outStream,const char*,...);
00078 void logEllipsisStart(outStream,const std::string);
00079 void logEllipsisEnd(outStream);
00080 void logProgressBarStart(outStream, const int);
00081 void logProgressBarNext(outStream);
00082 void logProgressBarEnd(outStream);
00083 void logProgressBarAgain(outStream);
00084 void logWarning(outStream,const std::string);
00085 void logElapsedTime(outStream);
00086
00087 bool isPackageCIMR() { return (PACKAGE == PACKAGE_CIMR); }
00088 bool isPackageCCP4() { return (PACKAGE == PACKAGE_CCP4); }
00089 bool isPackagePhenix() { return (PACKAGE == PACKAGE_PHENIX); }
00090 void setPackageCIMR();
00091 void setPackageCCP4();
00092 void setPackagePhenix();
00093
00094 void setVerbose(bool b,bool e) { VERBOSE_ON = b; DEBUG_ON = e; }
00095 void setSilent(bool b) { SILENT = b; }
00096 bool Verbose() { return VERBOSE_ON; }
00097 void setFileroot(std::string f) { FILEROOT = f; }
00098 void setXmlout(std::string f) { XMLOUT = true; XMLFILE = f; }
00099 void unsetXmlout() { XMLOUT = false; XMLFILE = ""; }
00100 bool doXmlout() { return XMLOUT; }
00101
00102 void WriteResult();
00103
00104 std::string Fileroot() { return FILEROOT; }
00105 std::string XmlFile() { return XMLFILE; }
00106 std::string Package();
00107
00108 std::string verbose() { return verboseString; }
00109 std::string logfile() { return logfileString; }
00110 std::string summary() { return summaryString; }
00111 std::string XML();
00112
00113 std::string version_date();
00114
00115
00116 std::string version_number();
00117
00118
00119 void SetMaxLineWidth(const int& Width) {max_line_width = Width;}
00120 };
00121
00122
00123 }
00124
00125 #endif