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 ELcout;
42 
43 
44 // ----------------------------------------------------------------------
45 // ErrorObj:
46 // ----------------------------------------------------------------------
47 
48 class ErrorObj {
49 
50 public:
51  // --- birth/death:
52  //
53  ErrorObj( const ELseverityLevel & sev,
54  const ELstring & id,
55  bool verbatim = false );
56  ErrorObj( const ErrorObj & orig ); // Same serial number and everything!
57  virtual ~ErrorObj();
58 
59  ErrorObj& operator=( const ErrorObj& other );
60  void swap ( ErrorObj& other );
61  // --- accessors:
62  //
63  int serial() const;
64  const ELextendedID & xid() const;
65  const ELstring & idOverflow() const;
66  time_t timestamp() const;
67  const ELlist_string & items() const;
68  bool reactedTo() const;
69  ELstring fullText() const;
70  ELstring context() const;
71  bool is_verbatim() const;
72 
73  // mutators:
74  //
75  virtual void setSeverity ( const ELseverityLevel & sev );
76  virtual void setID ( const ELstring & ID );
77  virtual void setModule ( const ELstring & module );
78  virtual void setSubroutine( const ELstring & subroutine );
79  virtual void setContext ( const ELstring & context );
80 
81  // ----- Methods for ErrorLog or for physicists logging errors:
82  //
83  template< class T >
84  inline ErrorObj & opltlt ( const T & t );
85  ErrorObj & opltlt ( const char s[] );
86  inline ErrorObj & operator<< ( std::ostream&(*f)(std::ostream&) );
87  inline ErrorObj & operator<< ( std::ios_base&(*f)(std::ios_base&) );
88 
89  virtual ErrorObj & emitToken( const ELstring & txt );
90 
91  // --- mutators for use by ELadministrator and ELtsErrorLog
92  //
93  virtual void set( const ELseverityLevel & sev, const ELstring & id );
94  virtual void clear();
95  virtual void setReactedTo ( bool r );
96 
97 private:
98 
99  // --- data members:
100  //
101  int mySerial;
104  time_t myTimestamp;
108  std::ostringstream myOs;
110  bool verbatim;
111 
112 }; // ErrorObj
113 
114 
115 // ----------------------------------------------------------------------
116 
117 
118 // ----- Method for physicists logging errors:
119 //
120 template< class T >
121 inline ErrorObj & operator<<( ErrorObj & e, const T & t );
122 
123 ErrorObj & operator<<( ErrorObj & e, const char s[] );
124 
125 
126 // ----------------------------------------------------------------------
127 
128 
129 // ----------------------------------------------------------------------
130 // Global functions:
131 // ----------------------------------------------------------------------
132 
133 inline
135  a.swap(b);
136 }
137 
138 } // end of namespace edm
139 
140 // ----------------------------------------------------------------------
141 // .icc
142 // ----------------------------------------------------------------------
143 
144 // The icc file contains the template for operator<< (ErrorObj&, T)
145 
146 #define ERROROBJ_ICC
147  #include "FWCore/MessageLogger/interface/ErrorObj.icc"
148 #undef ERROROBJ_ICC
149 
150 
151 // ----------------------------------------------------------------------
152 
153 
154 #endif // MessageLogger_ErrorObj_h
std::string emptyString
Definition: ErrorObj.h:109
time_t myTimestamp
Definition: ErrorObj.h:104
const ELstring & idOverflow() const
Definition: ErrorObj.cc:148
virtual ~ErrorObj()
Definition: ErrorObj.cc:113
virtual void setSeverity(const ELseverityLevel &sev)
Definition: ErrorObj.cc:174
ELstring myIdOverflow
Definition: ErrorObj.h:103
virtual void clear()
Definition: ErrorObj.cc:256
virtual void set(const ELseverityLevel &sev, const ELstring &id)
Definition: ErrorObj.cc:243
ErrorObj(const ELseverityLevel &sev, const ELstring &id, bool verbatim=false)
Definition: ErrorObj.cc:80
time_t timestamp() const
Definition: ErrorObj.cc:149
uint32_t ID
Definition: Definitions.h:26
virtual ErrorObj & emitToken(const ELstring &txt)
Definition: ErrorObj.cc:214
void swap(ErrorObj &other)
Definition: ErrorObj.cc:127
virtual void setSubroutine(const ELstring &subroutine)
Definition: ErrorObj.cc:194
ELlist_string myItems
Definition: ErrorObj.h:105
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
virtual void setContext(const ELstring &context)
Definition: ErrorObj.cc:191
virtual void setReactedTo(bool r)
Definition: ErrorObj.cc:204
const ELextendedID & xid() const
Definition: ErrorObj.cc:147
ELextendedID myXid
Definition: ErrorObj.h:102
ErrorObj & opltlt(const T &t)
ErrorObj & operator<<(std::ostream &(*f)(std::ostream &))
std::ostringstream myOs
Definition: ErrorObj.h:108
double f[11][100]
int serial() const
Definition: ErrorObj.cc:146
ELstring fullText() const
Definition: ErrorObj.cc:158
bool reactedTo() const
Definition: ErrorObj.cc:151
bool verbatim
Definition: ErrorObj.h:110
const ELlist_string & items() const
Definition: ErrorObj.cc:150
virtual void setID(const ELstring &ID)
Definition: ErrorObj.cc:182
ErrorObj & operator=(const ErrorObj &other)
Definition: ErrorObj.cc:121
double b
Definition: hdecay.h:120
std::list< ELstring > ELlist_string
Definition: ELlist.h:42
ELstring myContext
Definition: ErrorObj.h:107
double a
Definition: hdecay.h:121
bool myReactedTo
Definition: ErrorObj.h:106
bool is_verbatim() const
Definition: ErrorObj.cc:152
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:208
ELstring context() const
Definition: ErrorObj.cc:154
virtual void setModule(const ELstring &module)
Definition: ErrorObj.cc:189