CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ErrorObj.h
Go to the documentation of this file.
1 #ifndef MessageLogger_ErrorObj_h
2 #define MessageLogger_ErrorObj_h
3 
4 
5 // ----------------------------------------------------------------------
6 //
7 // ErrorObj is the representation of all information about an error
8 // message. The system uses this heavily: ErrorLog forms an
9 // ErrorObj to pass around to destinations. A physicist is
10 // permitted to use ErrorObj to form a message for potential
11 // logging.
12 //
13 // 7/8/98 mf Created file.
14 // 6/15/99 mf,jvr Inserted operator<<(void (*f)(ErrorLog&)
15 // 7/16/99 jvr Added setSeverity() and setID functions
16 // 6/6/00 web Adapt to consolidated ELcout/X
17 // 6/14/00 web Declare classes before granting friendship.
18 // 5/7/01 mf operator<< (const char[]) to avoid many instantiations of
19 // the template one for each length of potential error message
20 // 6/5/01 mf Made set() and clear() public. Added setReactedTo.
21 // 6/6/06 mf verbatim.
22 //
23 // ----------------------------------------------------------------------
24 
25 
30 
31 #include <sstream>
32 #include <string>
33 
34 namespace edm {
35 
36 
37 // ----------------------------------------------------------------------
38 // Prerequisite classes:
39 // ----------------------------------------------------------------------
40 
41 class ELcontextSupplier;
42 class ErrorLog;
43 class ELadministrator;
44 class ELcout;
45 
46 
47 // ----------------------------------------------------------------------
48 // ErrorObj:
49 // ----------------------------------------------------------------------
50 
51 class ErrorObj {
52 
53 public:
54  // --- birth/death:
55  //
56  ErrorObj( const ELseverityLevel & sev,
57  const ELstring & id,
58  bool verbatim = false );
59  ErrorObj( const ErrorObj & orig ); // Same serial number and everything!
60  virtual ~ErrorObj();
61 
62  // --- accessors:
63  //
64  int serial() const;
65  const ELextendedID & xid() const;
66  const ELstring & idOverflow() const;
67  time_t timestamp() const;
68  const ELlist_string & items() const;
69  bool reactedTo() const;
70  ELstring fullText() const;
71  ELstring context() const;
72  bool is_verbatim() const;
73 
74  // mutators:
75  //
76  virtual void setSeverity ( const ELseverityLevel & sev );
77  virtual void setID ( const ELstring & ID );
78  virtual void setModule ( const ELstring & module );
79  virtual void setSubroutine( const ELstring & subroutine );
80  virtual void setContext ( const ELstring & context );
81  virtual void setProcess ( const ELstring & proc );
82  //-| process is always determined through ErrorLog or
83  //-| an ELdestControl, both of which talk to ELadministrator.
84 
85  // ----- Methods for ErrorLog or for physicists logging errors:
86  //
87  template< class T >
88  inline ErrorObj & opltlt ( const T & t );
89  ErrorObj & opltlt ( const char s[] );
90  inline ErrorObj & operator<< ( std::ostream&(*f)(std::ostream&) );
91  inline ErrorObj & operator<< ( std::ios_base&(*f)(std::ios_base&) );
92 
93  virtual ErrorObj & emitToken( const ELstring & txt );
94 
95  // --- mutators for use by ELadministrator and ELtsErrorLog
96  //
97  virtual void set( const ELseverityLevel & sev, const ELstring & id );
98  virtual void clear();
99  virtual void setReactedTo ( bool r );
100 
101 private:
102  // --- class-wide serial number stamper:
103  //
104  static int ourSerial;
105 
106  // --- data members:
107  //
108  int mySerial;
111  time_t myTimestamp;
115  std::ostringstream myOs;
116  std::string emptyString;
117  bool verbatim;
118 
119 }; // ErrorObj
120 
121 
122 // ----------------------------------------------------------------------
123 
124 
125 // ----- Method for ErrorLog or for physicists logging errors:
126 //
127 template< class T >
128 inline ErrorObj & operator<<( ErrorObj & e, const T & t );
129 
130 ErrorObj & operator<<( ErrorObj & e, const char s[] );
131 
132 
133 // ----------------------------------------------------------------------
134 
135 
136 // ----------------------------------------------------------------------
137 // Global functions:
138 // ----------------------------------------------------------------------
139 
140 void endmsg( ErrorLog & );
141 
142 } // end of namespace edm
143 
144 
145 // ----------------------------------------------------------------------
146 // .icc
147 // ----------------------------------------------------------------------
148 
149 // The icc file contains the template for operator<< (ErrorObj&, T)
150 
151 #define ERROROBJ_ICC
152  #include "FWCore/MessageLogger/interface/ErrorObj.icc"
153 #undef ERROROBJ_ICC
154 
155 
156 // ----------------------------------------------------------------------
157 
158 
159 #endif // MessageLogger_ErrorObj_h
std::string emptyString
Definition: ErrorObj.h:116
time_t myTimestamp
Definition: ErrorObj.h:111
const ELstring & idOverflow() const
Definition: ErrorObj.cc:127
virtual ~ErrorObj()
Definition: ErrorObj.cc:112
virtual void setSeverity(const ELseverityLevel &sev)
Definition: ErrorObj.cc:153
ELstring myIdOverflow
Definition: ErrorObj.h:110
virtual void clear()
Definition: ErrorObj.cc:242
virtual void set(const ELseverityLevel &sev, const ELstring &id)
Definition: ErrorObj.cc:229
ErrorObj(const ELseverityLevel &sev, const ELstring &id, bool verbatim=false)
Definition: ErrorObj.cc:79
TrainProcessor *const proc
Definition: MVATrainer.cc:101
time_t timestamp() const
Definition: ErrorObj.cc:128
uint32_t ID
Definition: Definitions.h:26
virtual ErrorObj & emitToken(const ELstring &txt)
Definition: ErrorObj.cc:200
void endmsg(ErrorLog &)
virtual void setSubroutine(const ELstring &subroutine)
Definition: ErrorObj.cc:173
ELlist_string myItems
Definition: ErrorObj.h:112
virtual void setContext(const ELstring &context)
Definition: ErrorObj.cc:170
virtual void setReactedTo(bool r)
Definition: ErrorObj.cc:190
const ELextendedID & xid() const
Definition: ErrorObj.cc:126
ELextendedID myXid
Definition: ErrorObj.h:109
ErrorObj & opltlt(const T &t)
ErrorObj & operator<<(std::ostream &(*f)(std::ostream &))
std::ostringstream myOs
Definition: ErrorObj.h:115
double f[11][100]
int serial() const
Definition: ErrorObj.cc:125
ELstring fullText() const
Definition: ErrorObj.cc:137
bool reactedTo() const
Definition: ErrorObj.cc:130
bool verbatim
Definition: ErrorObj.h:117
const ELlist_string & items() const
Definition: ErrorObj.cc:129
virtual void setID(const ELstring &ID)
Definition: ErrorObj.cc:161
std::list< ELstring > ELlist_string
Definition: ELlist.h:42
ELstring myContext
Definition: ErrorObj.h:114
virtual void setProcess(const ELstring &proc)
Definition: ErrorObj.cc:183
bool myReactedTo
Definition: ErrorObj.h:113
static int ourSerial
Definition: ErrorObj.h:104
string s
Definition: asciidump.py:422
bool is_verbatim() const
Definition: ErrorObj.cc:131
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
long double T
std::string ELstring
Definition: ELstring.h:26
Definition: vlib.h:209
ELstring context() const
Definition: ErrorObj.cc:133
virtual void setModule(const ELstring &module)
Definition: ErrorObj.cc:168