CMS 3D CMS Logo

ELadministrator.h

Go to the documentation of this file.
00001 #ifndef MessageService_ELadministrator_h
00002 #define MessageService_ELadministrator_h
00003 
00004 
00005 // ----------------------------------------------------------------------
00006 //
00007 // ELadminstrator.h  provides the singleton class that the framework uses to
00008 //                   control logger behavior including attaching destinations.
00009 //              Includes the methods used by ErrorLog to evoke the logging
00010 //              behavior in the destinations owned by the ELadminstrator.
00011 //
00012 // ----------------------------------------------------------------------
00013 //
00014 // ELadministrator   The singleton logger class.  One does not instantiate
00015 //                   an ELadministrator.  Instead, do
00016 //                      ELadministrator * logger = ELadministrator::instance();
00017 //                   to get a pointer to the (unique) ELadministrator.
00018 //
00019 //      Only the framework should use ELadministrator directly.
00020 //      Physicist users get at it indirectly through using an ErrorLog
00021 //      set up in their Module class.
00022 //
00023 // ELadminDestroyer  A class whose sole purpose is the destruction of the
00024 //                   ELadministrator when the program is over.  Right now,
00025 //                   we do not have anything that needs to be done when the
00026 //                   ELadministrator (and thus the error logger) goes away;
00027 //                   but since by not deleting the copies of ELdestination's
00028 //                   that were attached we would be left with an apparent
00029 //                   memory leak, we include a protected destructor which will
00030 //                   clean up.  ELadminDestroyer provides the only way for
00031 //                   this destructor to be called.
00032 //
00033 // ----------------------------------------------------------------------
00034 //
00035 // 7/2/98 mf    Created file.
00036 // 2/29/00 mf   Added method swapContextSupplier for ELrecv to use.
00037 // 4/5/00 mf    Added method swapProcess for same reason:  ELrecv wants to
00038 //              be able to mock up the process and reset it afterward.
00039 // 6/6/00 web   Consolidate ELadministrator/X; adapt to consolidated
00040 //              ELcout/X.
00041 // 6/14/00 web  Declare classes before granting friendship.
00042 // 6/4/01  mf   Grant friedship to ELtsErrorLog
00043 // 3/6/02  mf   Items for recovering handles to attached destinations:
00044 //              the attachedDestinations map, 
00045 //              an additional signature for attach(), 
00046 //              and getELdestControl() method
00047 // 3/17/04 mf   exitThreshold and setExitThreshold
00048 // 1/10/06 mf   finish
00049 //
00050 // ----------------------------------------------------------------------
00051 
00052 #include "FWCore/MessageService/interface/ELdestControl.h"
00053 
00054 #include "FWCore/MessageLogger/interface/ELstring.h"
00055 #include "FWCore/MessageLogger/interface/ELlist.h"
00056 #include "FWCore/MessageLogger/interface/ELseverityLevel.h"
00057 #include "FWCore/MessageLogger/interface/ErrorObj.h"
00058 
00059 namespace edm {       
00060 namespace service {       
00061 
00062 
00063 // ----------------------------------------------------------------------
00064 // Prerequisite classes:
00065 // ----------------------------------------------------------------------
00066 
00067 class ELcontextSupplier;
00068 class ELdestination;
00069 class ELadminDestroyer;
00070 class ErrorLog;
00071 class ELtsErrorLog;
00072 class ELcout;
00073 
00074 
00075 // ----------------------------------------------------------------------
00076 // ELadministrator:
00077 // ----------------------------------------------------------------------
00078 
00079 class ELadministrator  {        // *** Destructable Singleton Pattern ***
00080 
00081   friend class ELadminDestroyer;        // proper ELadministrator cleanup
00082   friend class ErrorLog;                // ELadministrator user behavior
00083   friend class ELcout;                  // ELcout behavior
00084   friend class ELtsErrorLog;            // which walks sink list
00085 
00086 // *** Error Logger Functionality ***
00087 
00088 public:
00089 
00090   // ---  birth via a surrogate:
00091   //
00092   static ELadministrator * instance();          // *** Singleton Pattern
00093 
00094   // ---  get/set fundamental properties:
00095   //
00096   void setProcess( const ELstring & process );
00097   ELstring swapProcess( const ELstring & process );
00098   void setContextSupplier( const ELcontextSupplier & supplier );
00099   const ELcontextSupplier & getContextSupplier() const;
00100   ELcontextSupplier & swapContextSupplier( ELcontextSupplier & cs );
00101   void setAbortThreshold( const ELseverityLevel & sev );
00102   void setExitThreshold ( const ELseverityLevel & sev );
00103 
00104   // ---  furnish/recall destinations:
00105   //
00106   ELdestControl attach( const ELdestination & sink );
00107   ELdestControl attach( const ELdestination & sink, const ELstring & name );
00108   bool getELdestControl ( const ELstring & name, ELdestControl & theControl );
00109 
00110   // ---  handle severity information:
00111   //
00112   ELseverityLevel  checkSeverity();
00113   int severityCount( const ELseverityLevel & sev ) const;
00114   int severityCount( const ELseverityLevel & from,
00115                      const ELseverityLevel & to ) const;
00116   void resetSeverityCount( const ELseverityLevel & sev );
00117   void resetSeverityCount( const ELseverityLevel & from,
00118                            const ELseverityLevel & to );
00119   void resetSeverityCount();                    // reset all
00120 
00121   // ---  apply the following actions to all attached destinations:
00122   //
00123   void setThresholds( const ELseverityLevel & sev );
00124   void setLimits    ( const ELstring        & id,  int limit    );
00125   void setLimits    ( const ELseverityLevel & sev, int limit    );
00126   void setIntervals ( const ELstring        & id,  int interval );
00127   void setIntervals ( const ELseverityLevel & sev, int interval );
00128   void setTimespans ( const ELstring        & id,  int seconds  );
00129   void setTimespans ( const ELseverityLevel & sev, int seconds  );
00130   void wipe();
00131   void finish();
00132   
00133 protected:
00134   // ---  member data accessors:
00135   //
00136   const ELstring              & process() const;
00137   ELcontextSupplier           & context() const;
00138   const ELseverityLevel       & abortThreshold() const;
00139   const ELseverityLevel       &  exitThreshold() const;
00140   std::list<ELdestination *>  & sinks();
00141   const ELseverityLevel       & highSeverity() const;
00142   int                           severityCounts( int lev ) const;
00143 
00144   // ---  actions on messages:
00145   //
00146   void finishMsg();
00147   void clearMsg();
00148 
00149 protected:
00150   // ---  traditional birth/death, but disallowed to users:
00151   //
00152   ELadministrator();
00153   virtual ~ELadministrator();
00154 
00155 private:
00156   // ---  reach the actual (single) ELadministrator's instantiation
00157   // ---  (the instance() method records the ELadminDestroyer object):
00158   //
00159   static ELadministrator * instance_;
00160 
00161   // ---  traditional member data:
00162   //
00163   ELstring                   process_;       
00164   ELcontextSupplier *        context_;       
00165   ELseverityLevel            abortThreshold_; 
00166   ELseverityLevel            exitThreshold_; 
00167   std::list<ELdestination *> sinks_;            
00168   ELseverityLevel            highSeverity_;
00169   int                        severityCounts_[ ELseverityLevel::nLevels ];
00170   edm::ErrorObj              msg;
00171   bool                       msgIsActive;
00172 
00173   std::map < ELstring, ELdestination* > attachedDestinations;
00174 
00175 };  // ELadministrator
00176 
00177 
00178 // ----------------------------------------------------------------------
00179 // ELadminDestroyer:
00180 // ----------------------------------------------------------------------
00181 
00182 class ELadminDestroyer  {
00183 
00184 public:
00185   // ---  birth/death:
00186   //
00187   ELadminDestroyer( ELadministrator * ad = 0 );
00188  ~ELadminDestroyer();
00189 
00190   // ---  record our (single) self:
00191   //
00192   void setELadmin( ELadministrator * ad );
00193 
00194 private:
00195   // ---  member data:
00196   //
00197   ELadministrator * admin_;     // keep track of our (single) self
00198 
00199 };  // ELadminDestroyer
00200 
00201 
00202 // ----------------------------------------------------------------------
00203 
00204 
00205 }        // end of namespace service
00206 }        // end of namespace edm
00207 
00208 
00209 #endif  // MessageService_ELadministrator_h

Generated on Tue Jun 9 17:36:17 2009 for CMSSW by  doxygen 1.5.4