CMS 3D CMS Logo

ErrorObj.h
Go to the documentation of this file.
1 #ifndef MessageLogger_ErrorObj_h
2 #define MessageLogger_ErrorObj_h
3 
4 // ----------------------------------------------------------------------
5 //
6 // ErrorObj is the representation of all information about an error
7 // message. The system uses this heavily: ErrorLog forms an
8 // ErrorObj to pass around to destinations. A physicist is
9 // permitted to use ErrorObj to form a message for potential
10 // logging.
11 //
12 // 7/8/98 mf Created file.
13 // 6/15/99 mf,jvr Inserted operator<<(void (*f)(ErrorLog&)
14 // 7/16/99 jvr Added setSeverity() and setID functions
15 // 6/6/00 web Adapt to consolidated ELcout/X
16 // 6/14/00 web Declare classes before granting friendship.
17 // 5/7/01 mf operator<< (const char[]) to avoid many instantiations of
18 // the template one for each length of potential error message
19 // 6/5/01 mf Made set() and clear() public. Added setReactedTo.
20 // 6/6/06 mf verbatim.
21 //
22 // ----------------------------------------------------------------------
23 
28 
29 #include <sstream>
30 #include <string>
31 
32 namespace edm {
33 
34  // ----------------------------------------------------------------------
35  // Prerequisite classes:
36  // ----------------------------------------------------------------------
37 
38  class ELcout;
39 
40  // ----------------------------------------------------------------------
41  // ErrorObj:
42  // ----------------------------------------------------------------------
43 
44  class ErrorObj {
45  public:
46  // --- birth/death:
47  //
48  ErrorObj(const ELseverityLevel& sev, const ELstring& id, bool verbatim = false);
49  ErrorObj(const ErrorObj& orig); // Same serial number and everything!
50  virtual ~ErrorObj();
51 
53  void swap(ErrorObj& other);
54  // --- accessors:
55  //
56  int serial() const;
57  const ELextendedID& xid() const;
58  const ELstring& idOverflow() const;
59  time_t timestamp() const;
60  const ELlist_string& items() const;
61  bool reactedTo() const;
62  ELstring fullText() const;
63  ELstring context() const;
64  bool is_verbatim() const;
65 
66  // mutators:
67  //
68  virtual void setSeverity(const ELseverityLevel& sev);
69  virtual void setID(const ELstring& ID);
70  virtual void setModule(const ELstring& module);
71  virtual void setSubroutine(const ELstring& subroutine);
72  virtual void setContext(const std::string_view& context);
73 
74  // ----- Methods for ErrorLog or for physicists logging errors:
75  //
76  template <class T>
77  inline ErrorObj& opltlt(const T& t);
78  ErrorObj& opltlt(const char s[]);
79  inline ErrorObj& operator<<(std::ostream& (*f)(std::ostream&));
80  inline ErrorObj& operator<<(std::ios_base& (*f)(std::ios_base&));
81 
82  virtual ErrorObj& emitToken(const ELstring& txt);
83 
84  // --- mutators for use by ELadministrator and ELtsErrorLog
85  //
86  virtual void set(const ELseverityLevel& sev, const ELstring& id);
87  virtual void clear();
88  virtual void setReactedTo(bool r);
89 
90  private:
91  // --- data members:
92  //
93  int mySerial;
96  time_t myTimestamp;
100  std::ostringstream myOs;
102  bool verbatim;
103 
104  }; // ErrorObj
105 
106  // ----------------------------------------------------------------------
107 
108  // ----- Method for physicists logging errors:
109  //
110  template <class T>
111  inline ErrorObj& operator<<(ErrorObj& e, const T& t);
112 
113  ErrorObj& operator<<(ErrorObj& e, const char s[]);
114 
115  // ----------------------------------------------------------------------
116 
117  // ----------------------------------------------------------------------
118  // Global functions:
119  // ----------------------------------------------------------------------
120 
121  inline void swap(ErrorObj& a, ErrorObj& b) { a.swap(b); }
122 
123 } // end of namespace edm
124 
125 // ----------------------------------------------------------------------
126 // .icc
127 // ----------------------------------------------------------------------
128 
129 // The icc file contains the template for operator<< (ErrorObj&, T)
130 
131 #define ERROROBJ_ICC
132 #include "FWCore/MessageLogger/interface/ErrorObj.icc"
133 #undef ERROROBJ_ICC
134 
135 // ----------------------------------------------------------------------
136 
137 #endif // MessageLogger_ErrorObj_h
std::string emptyString
Definition: ErrorObj.h:101
time_t myTimestamp
Definition: ErrorObj.h:96
const ELstring & idOverflow() const
Definition: ErrorObj.cc:134
virtual ~ErrorObj()
Definition: ErrorObj.cc:100
virtual void setSeverity(const ELseverityLevel &sev)
Definition: ErrorObj.cc:154
ELstring myIdOverflow
Definition: ErrorObj.h:95
virtual void clear()
Definition: ErrorObj.cc:218
ErrorObj(const ELseverityLevel &sev, const ELstring &id, bool verbatim=false)
Definition: ErrorObj.cc:74
time_t timestamp() const
Definition: ErrorObj.cc:135
uint32_t ID
Definition: Definitions.h:24
virtual ErrorObj & emitToken(const ELstring &txt)
Definition: ErrorObj.cc:182
void swap(ErrorObj &other)
Definition: ErrorObj.cc:113
virtual void setSubroutine(const ELstring &subroutine)
Definition: ErrorObj.cc:169
ELlist_string myItems
Definition: ErrorObj.h:97
virtual void setReactedTo(bool r)
Definition: ErrorObj.cc:176
const ELextendedID & xid() const
Definition: ErrorObj.cc:133
ELextendedID myXid
Definition: ErrorObj.h:94
ErrorObj & opltlt(const T &t)
ErrorObj & operator<<(std::ostream &(*f)(std::ostream &))
std::ostringstream myOs
Definition: ErrorObj.h:100
double f[11][100]
virtual void setContext(const std::string_view &context)
Definition: ErrorObj.cc:167
int serial() const
Definition: ErrorObj.cc:132
ELstring fullText() const
Definition: ErrorObj.cc:142
bool reactedTo() const
Definition: ErrorObj.cc:137
bool verbatim
Definition: ErrorObj.h:102
const ELlist_string & items() const
Definition: ErrorObj.cc:136
virtual void setID(const ELstring &ID)
Definition: ErrorObj.cc:159
ErrorObj & operator=(const ErrorObj &other)
Definition: ErrorObj.cc:107
double b
Definition: hdecay.h:118
ELstring myContext
Definition: ErrorObj.h:99
HLT enums.
double a
Definition: hdecay.h:119
bool myReactedTo
Definition: ErrorObj.h:98
std::list< ELstring > ELlist_string
Definition: ELlist.h:36
bool is_verbatim() const
Definition: ErrorObj.cc:138
long double T
std::string ELstring
Definition: ELstring.h:21
Definition: vlib.h:198
ELstring context() const
Definition: ErrorObj.cc:140
int mySerial
Definition: ErrorObj.h:93
virtual void setModule(const ELstring &module)
Definition: ErrorObj.cc:165