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  ErrorObj& operator=( const ErrorObj& other );
63  void swap ( ErrorObj& other );
64  // --- accessors:
65  //
66  int serial() const;
67  const ELextendedID & xid() const;
68  const ELstring & idOverflow() const;
69  time_t timestamp() const;
70  const ELlist_string & items() const;
71  bool reactedTo() const;
72  ELstring fullText() const;
73  ELstring context() const;
74  bool is_verbatim() const;
75 
76  // mutators:
77  //
78  virtual void setSeverity ( const ELseverityLevel & sev );
79  virtual void setID ( const ELstring & ID );
80  virtual void setModule ( const ELstring & module );
81  virtual void setSubroutine( const ELstring & subroutine );
82  virtual void setContext ( const ELstring & context );
83  virtual void setProcess ( const ELstring & proc );
84  //-| process is always determined through ErrorLog or
85  //-| an ELdestControl, both of which talk to ELadministrator.
86 
87  // ----- Methods for ErrorLog or for physicists logging errors:
88  //
89  template< class T >
90  inline ErrorObj & opltlt ( const T & t );
91  ErrorObj & opltlt ( const char s[] );
92  inline ErrorObj & operator<< ( std::ostream&(*f)(std::ostream&) );
93  inline ErrorObj & operator<< ( std::ios_base&(*f)(std::ios_base&) );
94 
95  virtual ErrorObj & emitToken( const ELstring & txt );
96 
97  // --- mutators for use by ELadministrator and ELtsErrorLog
98  //
99  virtual void set( const ELseverityLevel & sev, const ELstring & id );
100  virtual void clear();
101  virtual void setReactedTo ( bool r );
102 
103 private:
104  // --- class-wide serial number stamper:
105  //
106  static int ourSerial;
107 
108  // --- data members:
109  //
110  int mySerial;
113  time_t myTimestamp;
117  std::ostringstream myOs;
119  bool verbatim;
120 
121 }; // ErrorObj
122 
123 
124 // ----------------------------------------------------------------------
125 
126 
127 // ----- Method for ErrorLog or for physicists logging errors:
128 //
129 template< class T >
130 inline ErrorObj & operator<<( ErrorObj & e, const T & t );
131 
132 ErrorObj & operator<<( ErrorObj & e, const char s[] );
133 
134 
135 // ----------------------------------------------------------------------
136 
137 
138 // ----------------------------------------------------------------------
139 // Global functions:
140 // ----------------------------------------------------------------------
141 
142 void endmsg( ErrorLog & );
143 
144 inline
146  a.swap(b);
147 }
148 
149 } // end of namespace edm
150 
151 // ----------------------------------------------------------------------
152 // .icc
153 // ----------------------------------------------------------------------
154 
155 // The icc file contains the template for operator<< (ErrorObj&, T)
156 
157 #define ERROROBJ_ICC
158  #include "FWCore/MessageLogger/interface/ErrorObj.icc"
159 #undef ERROROBJ_ICC
160 
161 
162 // ----------------------------------------------------------------------
163 
164 
165 #endif // MessageLogger_ErrorObj_h
std::string emptyString
Definition: ErrorObj.h:118
time_t myTimestamp
Definition: ErrorObj.h:113
const ELstring & idOverflow() const
Definition: ErrorObj.cc:147
virtual ~ErrorObj()
Definition: ErrorObj.cc:112
virtual void setSeverity(const ELseverityLevel &sev)
Definition: ErrorObj.cc:173
ELstring myIdOverflow
Definition: ErrorObj.h:112
virtual void clear()
Definition: ErrorObj.cc:262
virtual void set(const ELseverityLevel &sev, const ELstring &id)
Definition: ErrorObj.cc:249
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:148
uint32_t ID
Definition: Definitions.h:26
virtual ErrorObj & emitToken(const ELstring &txt)
Definition: ErrorObj.cc:220
void swap(ErrorObj &other)
Definition: ErrorObj.cc:126
void endmsg(ErrorLog &)
virtual void setSubroutine(const ELstring &subroutine)
Definition: ErrorObj.cc:193
ELlist_string myItems
Definition: ErrorObj.h:114
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
virtual void setContext(const ELstring &context)
Definition: ErrorObj.cc:190
virtual void setReactedTo(bool r)
Definition: ErrorObj.cc:210
const ELextendedID & xid() const
Definition: ErrorObj.cc:146
ELextendedID myXid
Definition: ErrorObj.h:111
ErrorObj & opltlt(const T &t)
ErrorObj & operator<<(std::ostream &(*f)(std::ostream &))
std::ostringstream myOs
Definition: ErrorObj.h:117
double f[11][100]
int serial() const
Definition: ErrorObj.cc:145
ELstring fullText() const
Definition: ErrorObj.cc:157
bool reactedTo() const
Definition: ErrorObj.cc:150
bool verbatim
Definition: ErrorObj.h:119
const ELlist_string & items() const
Definition: ErrorObj.cc:149
virtual void setID(const ELstring &ID)
Definition: ErrorObj.cc:181
ErrorObj & operator=(const ErrorObj &other)
Definition: ErrorObj.cc:120
double b
Definition: hdecay.h:120
std::list< ELstring > ELlist_string
Definition: ELlist.h:42
ELstring myContext
Definition: ErrorObj.h:116
virtual void setProcess(const ELstring &proc)
Definition: ErrorObj.cc:203
double a
Definition: hdecay.h:121
bool myReactedTo
Definition: ErrorObj.h:115
static int ourSerial
Definition: ErrorObj.h:106
bool is_verbatim() const
Definition: ErrorObj.cc:151
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:153
virtual void setModule(const ELstring &module)
Definition: ErrorObj.cc:188