| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- File List
- File Members

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