00001 #ifndef FWCore_MessageLogger_MessageSender_h 00002 #define FWCore_MessageLogger_MessageSender_h 00003 00004 #include "FWCore/MessageLogger/interface/ELstring.h" 00005 #include "FWCore/MessageLogger/interface/ELseverityLevel.h" 00006 #include "FWCore/MessageLogger/interface/ErrorObj.h" 00007 #include "FWCore/MessageLogger/interface/ErrorSummaryEntry.h" 00008 00009 #include "boost/shared_ptr.hpp" 00010 00011 #include <map> 00012 00013 // Change log 00014 // 00015 // 1 mf 8/25/08 error summary information for LoggedErrorsSummary() 00016 // 00017 // 2 mf 6/22/09 add severity to LoggedErrorsSummary by using 00018 // ErrorSummaryEntry as map key 00019 // 00020 // 3 wmtan 6/22/11 Hold the ErrorObj with a shared pointer with a custom deleter. 00021 // The custom deleter takes over the function of the message sending from the MessageSender destructor. 00022 // This allows MessageSender to be copyable, which fixes the clang compilation errors. 00023 00024 00025 namespace edm 00026 { 00027 00028 typedef ErrorSummaryEntry ErrorSummaryMapKey; 00029 typedef std::map<ErrorSummaryMapKey, unsigned int>::iterator 00030 ErrorSummaryMapIterator; 00031 00032 class MessageSender 00033 { 00034 struct ErrorObjDeleter { 00035 ErrorObjDeleter() {} 00036 void operator()(ErrorObj * errorObjPtr); 00037 }; 00038 00039 public: 00040 // --- birth/death: 00041 MessageSender() : errorobj_p() {} 00042 MessageSender( ELseverityLevel const & sev, 00043 ELstring const & id, 00044 bool verbatim = false, bool suppressed = false ); 00045 ~MessageSender(); 00046 00047 // --- stream out the next part of a message: 00048 template< class T > 00049 MessageSender & 00050 operator<< ( T const & t ) 00051 { 00052 if (valid()) (*errorobj_p) << t; 00053 return *this; 00054 } 00055 00056 // static data: // change log 1 00057 static bool errorSummaryIsBeingKept; 00058 static bool freshError; 00059 static std::map<ErrorSummaryMapKey, unsigned int> errorSummaryMap; 00060 bool valid() { 00061 return errorobj_p != 0; 00062 } 00063 00064 private: 00065 // data: 00066 boost::shared_ptr<ErrorObj> errorobj_p; 00067 00068 }; // MessageSender 00069 00070 00071 } // namespace edm 00072 00073 00074 #endif // FWCore_MessageLogger_MessageSender_h