Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:42

0001 #ifndef MessageLogger_MessageLoggerDefaults_h
0002 #define MessageLogger_MessageLoggerDefaults_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:     MessageLogger
0007 // Class  :     MessageLoggerDefaults
0008 //
0009 /**\class MessageLoggerDefaults MessageLoggerDefaults.h 
0010 
0011  Description: Structure holding defaults for MessageLogger service configuration
0012 
0013  Usage:
0014     #include "FWCore/Utilities/interface/JobMode.h"
0015     edm::JobMode mode = somehowObtainJobMode();
0016     MessageLoggerDefaults mlDefaults (mode);
0017     ...
0018     PSet p;
0019     std::string threshold = 
0020        p.getUntrackedParameter<std::string>("threshold", mlDefaults.threshold);
0021 
0022 */
0023 
0024 //
0025 // Original Author:  M. Fischler
0026 //         Created:  Tues Jun 14 10:38:19 CST 2007
0027 //
0028 
0029 // Framework include files
0030 
0031 #include "FWCore/Utilities/interface/JobMode.h"
0032 
0033 // system include files
0034 
0035 #include <string>
0036 #include <vector>
0037 #include <map>
0038 #include <cassert>
0039 
0040 // Change log
0041 //
0042 // 6/15/07 mf   Original version
0043 //
0044 // -------------------------------------------------------
0045 
0046 // user include files
0047 
0048 // ----------------
0049 // Maintenance Tips
0050 // ----------------
0051 //
0052 // When default values change for one job mode of operation or another,
0053 // implement that change in the appropriate member function implemented
0054 // in HardwiredDefaults.cc.  For example, hardwireGridJobMode().
0055 //
0056 // When a new default is needed, add the item to the struct, and then place
0057 // the default value into the appropriate sections of the various member
0058 // functions in HardwiredDefaults.cc.
0059 // It may be necessary to supply values of that default for each of the modes,
0060 // even though the ErrorLogger default is suitable for all the modes but one.
0061 //
0062 // When the new default is of a type not already being accessed, also add
0063 // the accessor method in this header, and implement it in
0064 // MessageLoggerDefaults.cc following the pattern shown for existing items
0065 
0066 namespace edm {
0067   namespace service {
0068 
0069     struct MessageLoggerDefaults {
0070     public:
0071       static const int NO_VALUE_SET = -45654;
0072 
0073       struct Category {
0074         std::string threshold;
0075         int limit;
0076         int reportEvery;
0077         int timespan;
0078         Category() : threshold(""), limit(NO_VALUE_SET), reportEvery(NO_VALUE_SET), timespan(NO_VALUE_SET) {}
0079       };
0080 
0081       struct Destination {
0082         std::string threshold;
0083         std::map<std::string, Category> category;
0084         std::map<std::string, Category> sev;
0085         std::string output;
0086       };
0087 
0088       // publicly available collections and structures
0089 
0090       std::vector<std::string> categories;
0091       std::vector<std::string> destinations;
0092       std::vector<std::string> statistics;
0093       std::map<std::string, Destination> destination;
0094 
0095       // access to values set
0096 
0097       std::string threshold(std::string const& dest) const;
0098       std::string output(std::string const& dest) const;
0099 
0100       int limit(std::string const& dest, std::string const& cat) const;
0101       int reportEvery(std::string const& dest, std::string const& cat) const;
0102       int timespan(std::string const& dest, std::string const& cat) const;
0103 
0104       int sev_limit(std::string const& dest, std::string const& sev) const;
0105       int sev_reportEvery(std::string const& dest, std::string const& sev) const;
0106       int sev_timespan(std::string const& dest, std::string const& sev) const;
0107 
0108       // Modes with hardwired defaults
0109 
0110       void hardwireGridJobMode();
0111       void hardwireReleaseValidationJobMode();
0112       void hardwireAnalysisJobMode();
0113       void hardwireNilJobMode();
0114 
0115       static edm::JobMode mode(std::string const& jm);
0116 
0117       // ctor
0118 
0119       explicit MessageLoggerDefaults(edm::JobMode mode = GridJobMode) {
0120         // mode-independent defaults
0121 
0122         // mode-dependent defaults
0123         switch (mode) {
0124           // GridJobMode:   Intended for automated batch-like processing, in which
0125           //                the output stream for cerr is routed to an apropro
0126           //                file.  LogInfo messages are enabled, and at least
0127           //            one such message is delivered from the framework per
0128           //        event, so this mode is not suitable for many-Hz light
0129           //        event processing.
0130           case GridJobMode:
0131             hardwireGridJobMode();
0132             break;
0133           case ReleaseValidationJobMode:
0134             hardwireReleaseValidationJobMode();
0135             break;
0136           case AnalysisJobMode:
0137             hardwireAnalysisJobMode();
0138             break;
0139           case NilJobMode:
0140             hardwireNilJobMode();
0141             break;
0142           default:
0143             // this should never happen!  No user error can get here.
0144             bool Invalid_JobMode_in_ctor_of_MessageLoggerDefaults = false;
0145             assert(Invalid_JobMode_in_ctor_of_MessageLoggerDefaults);
0146         }  // end of switch on mode
0147       }
0148     };
0149 
0150   }  // end of namespace service
0151 }  // end of namespace edm
0152 
0153 #endif  // MessageLogger_MessageLoggerDefaults_h