| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# IssueSeverity.h

Go to the documentation of this file.

    00001 #ifndef GAUDIKERNEL_ISSUESEVERITY_H
    00002 #define GAUDIKERNEL_ISSUESEVERITY_H 1
    00003
    00004 class StatusCode;
    00005
    00006 #include <string>
    00007 #include <map>
    00008 #include <iostream>
    00009
    00010 #include "GaudiKernel/Kernel.h"
    00011
    00012 #define ISSUE(x,y) IssueSeverity(x,__LINE__,__FILE__,y)
    00013 #define STATUSCODE(z,x,y) StatusCode(z,ISSUE(x,y))
    00014
    00015 class IIssueLogger;
    00016
    00017 // namespace IS {
    00018 //   enum Level {
    00019 //     NIL = 0,
    00020 //     VERBOSE,
    00021 //     DEBUG,
    00022 //     DEBUG1,
    00023 //     DEBUG2,
    00024 //     DEBUG3,
    00025 //     INFO,
    00026 //     WARNING,
    00027 //     RECOVERABLE,
    00028 //     ERROR,
    00029 //     FATAL,
    00030 //     ALWAYS,
    00031 //     NUM_LEVELS
    00032 //   };
    00033 // }
    00034
    00035
    00036 #ifdef _WIN32
    00037 #ifdef ERROR
    00038 #undef ERROR
    00039 #endif
    00040 #endif
    00041
    00042 class GAUDI_API IssueSeverity {
    00043
    00044 public:
    00045
    00046   enum Level {
    00047     NIL = 0,
    00048     VERBOSE,
    00049     DEBUG,
    00050     DEBUG1,
    00051     DEBUG2,
    00052     DEBUG3,
    00053     INFO,
    00054     WARNING,
    00055     RECOVERABLE,
    00056     ERROR,
    00057     FATAL,
    00058     ALWAYS,
    00059     NUM_LEVELS
    00060   };
    00061
    00062   IssueSeverity();
    00063   IssueSeverity( const IssueSeverity::Level &level, int line,
    00064                  const std::string& file,
    00065                  const std::string& msg="");
    00066   IssueSeverity( const IssueSeverity::Level &level, const std::string& msg="");
    00067
    00068   IssueSeverity( const IssueSeverity& es );
    00069   IssueSeverity( IssueSeverity* es );
    00070
    00071   IssueSeverity& operator=(const IssueSeverity& rhs);
    00072
    00073   ~IssueSeverity();
    00074
    00075   void setLevel(const IssueSeverity::Level& l) {
    00076     m_level = l;
    00077   }
    00078   void setMsg(const std::string& m) {
    00079     m_msg = m;
    00080   }
    00081
    00082   IssueSeverity::Level getLevel() const { return m_level; }
    00083   std::string  getMsg() const { return m_msg; }
    00084   std::string  getOrigin() const;
    00085
    00086   void report();
    00087
    00088   operator StatusCode() const;
    00089
    00090   friend inline std::ostream& operator<< ( std::ostream&,
    00091                                            const IssueSeverity& ) ;
    00092
    00093 private:
    00094
    00095   int m_line;
    00096   std::string m_file;
    00097
    00098   static bool m_init;
    00099   static IIssueLogger* m_ers;
    00100
    00101   IssueSeverity::Level m_level;
    00102   std::string m_msg;
    00103   bool m_reported;
    00104
    00105   static void init();
    00106
    00107 };
    00108
    00109 inline IssueSeverity::IssueSeverity(): m_line(0), m_file(""),
    00110                                        m_level(IssueSeverity::NIL),
    00111                                        m_msg(""), m_reported(true) {}
    00112
    00113 inline IssueSeverity::IssueSeverity(const IssueSeverity::Level &level, int line,
    00114                                     const std::string& file,
    00115                                     const std::string& msg):
    00116   m_line(line), m_file(file), m_level(level), m_msg(msg), m_reported(false) {
    00117
    00118   init();
    00119   report();
    00120
    00121 }
    00122
    00123 inline IssueSeverity::IssueSeverity(const IssueSeverity::Level &level,
    00124                                     const std::string& msg):
    00125   m_line(0), m_file("??"), m_level(level), m_msg(msg), m_reported(false) {
    00126
    00127   init();
    00128   report();
    00129
    00130 }
    00131
    00132 inline IssueSeverity::IssueSeverity( const IssueSeverity& rhs ) {
    00133   m_line = rhs.m_line;
    00134   m_file = rhs.m_file;
    00135   m_level = rhs.m_level;
    00136   m_msg   = rhs.m_msg;
    00137   m_reported = true;
    00138 }
    00139
    00140 inline IssueSeverity::IssueSeverity( IssueSeverity* rhs ) {
    00141   m_line = rhs->m_line;
    00142   m_file = rhs->m_file;
    00143   m_level = rhs->m_level;
    00144   m_msg   = rhs->m_msg;
    00145   m_reported = true;
    00146 }
    00147
    00148 inline IssueSeverity& IssueSeverity::operator=(const IssueSeverity& rhs) {
    00149   m_line = rhs.m_line;
    00150   m_file = rhs.m_file;
    00151   m_level = rhs.m_level;
    00152   m_msg   = rhs.m_level;
    00153   m_reported = true;
    00154   return *this;
    00155 }
    00156
    00157 std::ostream& operator<< ( std::ostream& os , const IssueSeverity& rhs ) {
    00158   os << "ISSUE:  level " << rhs.getLevel() << " from: " << rhs.getOrigin()
    00159      << " msg: " << rhs.getMsg();
    00160   return os;
    00161 }
    00162
    00163
    00164 #endif