CMS 3D CMS Logo

ErrorObj.h

Go to the documentation of this file.
00001 #ifndef MessageLogger_ErrorObj_h
00002 #define MessageLogger_ErrorObj_h
00003 
00004 
00005 // ----------------------------------------------------------------------
00006 //
00007 // ErrorObj     is the representation of all information about an error
00008 //              message.  The system uses this heavily:  ErrorLog forms an
00009 //              ErrorObj to pass around to destinations.  A physicist is
00010 //              permitted to use ErrorObj to form a message for potential
00011 //              logging.
00012 //
00013 // 7/8/98  mf   Created file.
00014 // 6/15/99 mf,jvr  Inserted operator<<(void (*f)(ErrorLog&)
00015 // 7/16/99 jvr  Added setSeverity() and setID functions
00016 // 6/6/00 web   Adapt to consolidated ELcout/X
00017 // 6/14/00 web  Declare classes before granting friendship.
00018 // 5/7/01  mf   operator<< (const char[]) to avoid many instantiations of
00019 //              the template one for each length of potential error message
00020 // 6/5/01  mf   Made set() and clear() public.  Added setReactedTo.
00021 // 6/6/06  mf   verbatim.
00022 //
00023 // ----------------------------------------------------------------------
00024 
00025 
00026 #include "FWCore/MessageLogger/interface/ELstring.h"
00027 #include "FWCore/MessageLogger/interface/ELlist.h"
00028 #include "FWCore/MessageLogger/interface/ELextendedID.h"
00029 #include "FWCore/MessageLogger/interface/ELseverityLevel.h"
00030 
00031 #include <sstream>
00032 #include <string>
00033 
00034 namespace edm {       
00035 
00036 
00037 // ----------------------------------------------------------------------
00038 // Prerequisite classes:
00039 // ----------------------------------------------------------------------
00040 
00041 class ELcontextSupplier;
00042 class ErrorLog;
00043 class ELadministrator;
00044 class ELcout;
00045 
00046 
00047 // ----------------------------------------------------------------------
00048 // ErrorObj:
00049 // ----------------------------------------------------------------------
00050 
00051 class ErrorObj  {
00052 
00053 public:
00054   // --- birth/death:
00055   //
00056   ErrorObj( const ELseverityLevel & sev, 
00057             const ELstring & id, 
00058             bool verbatim = false );
00059   ErrorObj( const ErrorObj & orig );  // Same serial number and everything!
00060   virtual ~ErrorObj();
00061 
00062   // --- accessors:
00063   //
00064   int                    serial() const;
00065   const ELextendedID &   xid() const;
00066   const ELstring &       idOverflow() const;
00067   time_t                 timestamp() const;
00068   const ELlist_string &  items() const;
00069   bool                   reactedTo() const;
00070   ELstring               fullText() const;
00071   ELstring               context() const;
00072   bool                   is_verbatim() const;
00073 
00074   // mutators:
00075   //
00076   virtual void  setSeverity  ( const ELseverityLevel & sev );
00077   virtual void  setID        ( const ELstring & ID );
00078   virtual void  setModule    ( const ELstring & module );
00079   virtual void  setSubroutine( const ELstring & subroutine );
00080   virtual void  setContext   ( const ELstring & context );
00081   virtual void  setProcess   ( const ELstring & proc );
00082                 //-| process is always determined through ErrorLog or
00083                 //-| an ELdestControl, both of which talk to ELadministrator.
00084 
00085   // -----  Methods for ErrorLog or for physicists logging errors:
00086   //
00087   template< class T >
00088   inline ErrorObj &  opltlt ( const T & t );
00089          ErrorObj &  opltlt ( const char s[] );
00090   inline ErrorObj &  operator<< ( std::ostream&(*f)(std::ostream&) ); 
00091   inline ErrorObj &  operator<< ( std::ios_base&(*f)(std::ios_base&) ); 
00092 
00093   virtual ErrorObj &  emit( const ELstring & txt );
00094 
00095   // ---  mutators for use by ELadministrator and ELtsErrorLog
00096   //
00097   virtual void  set( const ELseverityLevel & sev, const ELstring & id );
00098   virtual void  clear();
00099   virtual void  setReactedTo ( bool r );
00100 
00101 private:
00102   // ---  class-wide serial number stamper:
00103   //
00104   static int     ourSerial;
00105 
00106   // ---  data members:
00107   //
00108   int            mySerial;
00109   ELextendedID   myXid;
00110   ELstring       myIdOverflow;
00111   time_t         myTimestamp;
00112   ELlist_string  myItems;
00113   bool           myReactedTo;
00114   ELstring       myContext;
00115   std::ostringstream myOs; 
00116   std::string    emptyString;
00117   bool           verbatim;
00118     
00119 };  // ErrorObj
00120 
00121 
00122 // ----------------------------------------------------------------------
00123 
00124 
00125 // -----  Method for ErrorLog or for physicists logging errors:
00126 //
00127 template< class T >
00128 inline ErrorObj &  operator<<( ErrorObj & e, const T & t );
00129 
00130 ErrorObj &  operator<<( ErrorObj & e, const char s[] );
00131 
00132 
00133 // ----------------------------------------------------------------------
00134 
00135 
00136 // ----------------------------------------------------------------------
00137 // Global functions:
00138 // ----------------------------------------------------------------------
00139 
00140 void endmsg( ErrorLog & );
00141 
00142 }        // end of namespace edm
00143 
00144 
00145 // ----------------------------------------------------------------------
00146 // .icc
00147 // ----------------------------------------------------------------------
00148 
00149 // The icc file contains the template for operator<< (ErrorObj&, T)
00150 
00151 #define ERROROBJ_ICC
00152   #include "FWCore/MessageLogger/interface/ErrorObj.icc"
00153 #undef  ERROROBJ_ICC
00154 
00155 
00156 // ----------------------------------------------------------------------
00157 
00158 
00159 #endif // MessageLogger_ErrorObj_h

Generated on Tue Jun 9 17:36:17 2009 for CMSSW by  doxygen 1.5.4