Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:03:24

0001 #ifndef ZMEXHANDLER_H
0002 #define ZMEXHANDLER_H
0003 
0004 
0005 // ----------------------------------------------------------------------
0006 //
0007 // ZMexHandler.h - interface class declarations for the ZOOM Exception
0008 //                 Handler base class and the basic handlers:
0009 //   ZMexThrowAlways
0010 //   ZMexIgnoreAlways
0011 //   ZMexThrowErrors
0012 //   ZMexIgnoreNextN
0013 //   ZMexHandleViaParent
0014 // These can be used as examples if custom handlers are desired.
0015 //
0016 // Revision History:
0017 //  970909  MF  Initial version
0018 //  970916  WEB Updated per code review
0019 //  970917  WEB Updated per code review 2
0020 //  970923  WEB Updated per code review 4
0021 //  971008  WEB ZMutility is the new name for the Utility package
0022 //      971112  WEB Updated for conformance to standard and the zoom
0023 //          compatability headers
0024 //  980615  WEB Added namespace support
0025 //      990318  MF      Modified intializer list orders to avoid warnings
0026 //  000217  WEB Improve C++ standards compliance
0027 //  000503  WEB Avoid global using
0028 //  031105  LG  Get rid of all ZMutility references
0029 //
0030 // ----------------------------------------------------------------------
0031 
0032 #ifndef STRING_INCLUDED
0033   #define STRING_INCLUDED
0034   #include <string>
0035 #endif
0036 
0037 #ifndef ZMHANDLETO_H
0038   #include "CLHEP/RefCount/ZMhandleTo.h"
0039 #endif
0040 
0041 #ifndef ZMEXSEVERITY_H
0042   #include "CLHEP/Exceptions/ZMexSeverity.h"
0043 #endif
0044 
0045 #ifndef ZMEXACTION_H
0046   #include "CLHEP/Exceptions/ZMexAction.h"
0047 #endif
0048 
0049 
0050 namespace zmex  {
0051 
0052 
0053 class ZMexception;
0054 
0055 
0056 //********************
0057 //
0058 // ZMexHandlerBehavior
0059 //
0060 //********************
0061 
0062 class ZMexHandlerBehavior {
0063   // Handler behavior interface definition
0064 
0065 public:
0066   ZMexHandlerBehavior(
0067     const std::string aname = "ZMexHandlerBehavior"
0068   ) : name_( aname ) { }
0069 
0070   virtual ~ZMexHandlerBehavior() { }
0071 
0072   virtual ZMexHandlerBehavior * clone() const  {
0073     return  new ZMexHandlerBehavior( *this );
0074   }
0075 
0076   virtual std::string name() const { return name_; }
0077   virtual ZMexAction takeCareOf( const ZMexception & ) { return ZMexThrowIt; }
0078 
0079 protected:
0080   /*virtual void handleLog( ZMexception & x, const int limit );*/
0081   ZMexAction standardHandling( const ZMexception & x, bool willThrow );
0082 
0083 private:
0084   const std::string name_;
0085 
0086 };  // ZMexHandlerBehavior
0087 
0088 
0089 
0090 //************
0091 //
0092 // ZMexHandler
0093 //
0094 //************
0095 
0096 class ZMexHandler  :  public ZMhandleTo< ZMexHandlerBehavior >  {
0097   // Handler interface
0098 
0099 public:
0100   ZMexHandler(
0101     const ZMexHandlerBehavior & behaviorWanted
0102   )  :
0103     ZMhandleTo<ZMexHandlerBehavior>( behaviorWanted )
0104   { }
0105 
0106   virtual ~ZMexHandler();
0107 
0108   std::string name() const {
0109     return  rep_->name();
0110   }
0111 
0112   virtual ZMexAction takeCareOf( const ZMexception & x )  {
0113     return  rep_->takeCareOf(x);
0114   }
0115 
0116   int setLogLimit( ZMexSeverity s, int limit ) {
0117     int lim = ZMexSeverityLimit[ s ];
0118     ZMexSeverityLimit[ s ] = limit;
0119     return  lim;
0120   }
0121 
0122 };  // ZMexHandler
0123 
0124 
0125 
0126 //****************
0127 //
0128 // ZMexThrowAlways
0129 //
0130 //****************
0131 
0132 class ZMexThrowAlways :  public ZMexHandlerBehavior {
0133 
0134 public:
0135   ZMexThrowAlways() : ZMexHandlerBehavior( "ZMexThrowAlways" ) { }
0136   virtual ZMexThrowAlways * clone() const;
0137   virtual ZMexAction takeCareOf( const ZMexception & x );
0138 };
0139 
0140 
0141 //****************
0142 //
0143 // ZMexThrowErrors
0144 //
0145 //****************
0146 
0147 class ZMexThrowErrors :  public ZMexHandlerBehavior {
0148 
0149 public:
0150   ZMexThrowErrors() : ZMexHandlerBehavior( "ZMexThrowErrors" ) { }
0151   virtual ZMexThrowErrors * clone() const;
0152   virtual ZMexAction takeCareOf( const ZMexception & x );
0153 };
0154 
0155 
0156 //*****************
0157 //
0158 // ZMexIgnoreAlways
0159 //
0160 //*****************
0161 
0162 class ZMexIgnoreAlways :  public ZMexHandlerBehavior {
0163 
0164 public:
0165   ZMexIgnoreAlways() : ZMexHandlerBehavior( "ZMexIgnoreAlways" ) { }
0166   virtual ZMexIgnoreAlways * clone() const;
0167   virtual ZMexAction takeCareOf( const ZMexception & x );
0168 };
0169 
0170 
0171 //*****************
0172 //
0173 // ZMexIgnoreNextN
0174 //
0175 //*****************
0176 
0177 class ZMexIgnoreNextN :  public ZMexHandlerBehavior {
0178 
0179 public:
0180   ZMexIgnoreNextN( int n ) :
0181     ZMexHandlerBehavior( "ZMexIgnoreNextN" ),
0182     countDown_( n )
0183   { }
0184   virtual ZMexIgnoreNextN * clone() const;
0185   virtual ZMexAction takeCareOf( const ZMexception & x );
0186 
0187 private:
0188   int countDown_;
0189 };
0190 
0191 
0192 //******************
0193 //
0194 // ZMexHandleViaParent
0195 //
0196 //******************
0197 
0198 class ZMexHandleViaParent :  public ZMexHandlerBehavior {
0199 public:
0200   ZMexHandleViaParent() : ZMexHandlerBehavior( "" ) { }
0201   virtual ZMexHandleViaParent * clone() const;
0202   virtual ZMexAction takeCareOf( const ZMexception & x );
0203 };
0204 
0205 
0206 }  // namespace zmex
0207 
0208 
0209 #define ZMEXHANDLER_ICC
0210 #include "CLHEP/Exceptions/ZMexHandler.icc"
0211 #undef ZMEXHANDLER_ICC
0212 
0213 
0214 #endif  // ZMEXHANDLER_H