CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/FWCore/MessageLogger/interface/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   ErrorObj& operator=( const ErrorObj& other );
00063   void swap ( ErrorObj& other );
00064   // --- accessors:
00065   //
00066   int                    serial() const;
00067   const ELextendedID &   xid() const;
00068   const ELstring &       idOverflow() const;
00069   time_t                 timestamp() const;
00070   const ELlist_string &  items() const;
00071   bool                   reactedTo() const;
00072   ELstring               fullText() const;
00073   ELstring               context() const;
00074   bool                   is_verbatim() const;
00075 
00076   // mutators:
00077   //
00078   virtual void  setSeverity  ( const ELseverityLevel & sev );
00079   virtual void  setID        ( const ELstring & ID );
00080   virtual void  setModule    ( const ELstring & module );
00081   virtual void  setSubroutine( const ELstring & subroutine );
00082   virtual void  setContext   ( const ELstring & context );
00083   virtual void  setProcess   ( const ELstring & proc );
00084                 //-| process is always determined through ErrorLog or
00085                 //-| an ELdestControl, both of which talk to ELadministrator.
00086 
00087   // -----  Methods for ErrorLog or for physicists logging errors:
00088   //
00089   template< class T >
00090   inline ErrorObj &  opltlt ( const T & t );
00091          ErrorObj &  opltlt ( const char s[] );
00092   inline ErrorObj &  operator<< ( std::ostream&(*f)(std::ostream&) ); 
00093   inline ErrorObj &  operator<< ( std::ios_base&(*f)(std::ios_base&) ); 
00094 
00095   virtual ErrorObj &  emitToken( const ELstring & txt );
00096 
00097   // ---  mutators for use by ELadministrator and ELtsErrorLog
00098   //
00099   virtual void  set( const ELseverityLevel & sev, const ELstring & id );
00100   virtual void  clear();
00101   virtual void  setReactedTo ( bool r );
00102 
00103 private:
00104   // ---  class-wide serial number stamper:
00105   //
00106   static int     ourSerial;
00107 
00108   // ---  data members:
00109   //
00110   int            mySerial;
00111   ELextendedID   myXid;
00112   ELstring       myIdOverflow;
00113   time_t         myTimestamp;
00114   ELlist_string  myItems;
00115   bool           myReactedTo;
00116   ELstring       myContext;
00117   std::ostringstream myOs; 
00118   std::string    emptyString;
00119   bool           verbatim;
00120     
00121 };  // ErrorObj
00122 
00123 
00124 // ----------------------------------------------------------------------
00125 
00126 
00127 // -----  Method for ErrorLog or for physicists logging errors:
00128 //
00129 template< class T >
00130 inline ErrorObj &  operator<<( ErrorObj & e, const T & t );
00131 
00132 ErrorObj &  operator<<( ErrorObj & e, const char s[] );
00133 
00134 
00135 // ----------------------------------------------------------------------
00136 
00137 
00138 // ----------------------------------------------------------------------
00139 // Global functions:
00140 // ----------------------------------------------------------------------
00141 
00142 void endmsg( ErrorLog & );
00143 
00144 inline
00145 void swap(ErrorObj& a, ErrorObj& b) {
00146   a.swap(b);
00147 }
00148 
00149 }        // end of namespace edm
00150 
00151 // ----------------------------------------------------------------------
00152 // .icc
00153 // ----------------------------------------------------------------------
00154 
00155 // The icc file contains the template for operator<< (ErrorObj&, T)
00156 
00157 #define ERROROBJ_ICC
00158   #include "FWCore/MessageLogger/interface/ErrorObj.icc"
00159 #undef  ERROROBJ_ICC
00160 
00161 
00162 // ----------------------------------------------------------------------
00163 
00164 
00165 #endif // MessageLogger_ErrorObj_h