cdiAux.h

00001 #ifndef cdiAux_H
00002 #define cdiAux_H
00003 
00005 //
00006 //   cdiAux.h        Luis Pedro, November 2003, Serguei Kolos May 2004
00007 //
00008 //
00009 //   cdiAux class:Provides a set of generic utilities for the
00010 //           CDI component. It also provides a facility to allow
00011 //           several degrees of verbosity to STDOUT and STDERR.
00012 //
00013 //   info: printout a CDI message if the verbosity level of the message is
00014 //         equal or inferior to the level of verbosity set by the application.
00015 //
00016 //   error: printout a formatted error message, also taking into consideration
00017 //         the verbosity level.
00018 //
00020 
00021 
00022 #include <string>
00023 #include <owl/time.h>
00024 
00025 class cdiAux 
00026 {
00027   int verbosity_;
00028  public:
00029   
00030   cdiAux( int verbosity = 1 ) : verbosity_(verbosity) { ; }
00031   
00032   void info ( const std::string & msg, int verbosity = 1 ) const {
00033     if (verbosity <= verbosity_)
00034       std::cout << "[CDI INFO    (" << OWLTime() <<  ") ] " << msg << std::endl;
00035   }
00036   
00037   void warning ( const std::string & msg, int verbosity = 1 ) const {
00038     if (verbosity <= verbosity_)
00039       std::cout << "[CDI WARNING (" << OWLTime() <<  ") ] " << msg << std::endl;
00040   }
00041 
00042   void error ( const std::string & msg, int verbosity = 0  ) const {
00043     if (verbosity <= verbosity_)
00044       std::cout << "[CDI ERROR   (" << OWLTime() <<  ") ] " << msg << std::endl;
00045   }
00046   
00047   void debug (const std::string & msg, int verbosity = 2 ) const {
00048     if (verbosity <= verbosity_)
00049       std::cout << "[CDI DEBUG   (" << OWLTime() <<  ") ] " << msg << std::endl;
00050   }
00051 
00052   void verbose (const std::string & msg, int verbosity = 3 ) const {
00053     if (verbosity <= verbosity_)
00054       std::cout << "[CDI VERBOSE (" << OWLTime() <<  ") ] " << msg << std::endl;
00055   }
00056 
00057   void verbose (const char*msg, int verbosity = 3 ) const {
00058     this->verbose(std::string(msg),verbosity);
00059   }
00060   void debug (const char*msg, int verbosity = 2 ) const {
00061     this->debug(std::string(msg),verbosity);
00062   }
00063   void error (const char*msg, int verbosity = 0 ) const {
00064     this->error(std::string(msg),verbosity);
00065   }
00066   void info (const char*msg, int verbosity = 1 ) const {
00067     this->info(std::string(msg),verbosity);
00068   }
00069 
00070   void warning (const char*msg, int verbosity = 1 ) const {
00071     this->warning(std::string(msg),verbosity);
00072   }
00073 
00074 };            
00075 
00076 #endif //cdiAux_H

Generated on Mon Feb 6 14:01:17 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6