CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 #ifndef ZMEXHANDLER_H 00002 #define ZMEXHANDLER_H 00003 00004 00005 // ---------------------------------------------------------------------- 00006 // 00007 // ZMexHandler.h - interface class declarations for the ZOOM Exception 00008 // Handler base class and the basic handlers: 00009 // ZMexThrowAlways 00010 // ZMexIgnoreAlways 00011 // ZMexThrowErrors 00012 // ZMexIgnoreNextN 00013 // ZMexHandleViaParent 00014 // These can be used as examples if custom handlers are desired. 00015 // 00016 // Revision History: 00017 // 970909 MF Initial version 00018 // 970916 WEB Updated per code review 00019 // 970917 WEB Updated per code review 2 00020 // 970923 WEB Updated per code review 4 00021 // 971008 WEB ZMutility is the new name for the Utility package 00022 // 971112 WEB Updated for conformance to standard and the zoom 00023 // compatability headers 00024 // 980615 WEB Added namespace support 00025 // 990318 MF Modified intializer list orders to avoid warnings 00026 // 000217 WEB Improve C++ standards compliance 00027 // 000503 WEB Avoid global using 00028 // 031105 LG Get rid of all ZMutility references 00029 // 00030 // ---------------------------------------------------------------------- 00031 00032 #ifndef STRING_INCLUDED 00033 #define STRING_INCLUDED 00034 #include <string> 00035 #endif 00036 00037 #ifndef ZMHANDLETO_H 00038 #include "CLHEP/RefCount/ZMhandleTo.h" 00039 #endif 00040 00041 #ifndef ZMEXSEVERITY_H 00042 #include "CLHEP/Exceptions/ZMexSeverity.h" 00043 #endif 00044 00045 #ifndef ZMEXACTION_H 00046 #include "CLHEP/Exceptions/ZMexAction.h" 00047 #endif 00048 00049 00050 namespace zmex { 00051 00052 00053 class ZMexception; 00054 00055 00056 //******************** 00057 // 00058 // ZMexHandlerBehavior 00059 // 00060 //******************** 00061 00062 class ZMexHandlerBehavior { 00063 // Handler behavior interface definition 00064 00065 public: 00066 ZMexHandlerBehavior( 00067 const std::string aname = "ZMexHandlerBehavior" 00068 ) : name_( aname ) { } 00069 00070 virtual ~ZMexHandlerBehavior() { } 00071 00072 virtual ZMexHandlerBehavior * clone() const { 00073 return new ZMexHandlerBehavior( *this ); 00074 } 00075 00076 virtual std::string name() const { return name_; } 00077 virtual ZMexAction takeCareOf( const ZMexception & ) { return ZMexThrowIt; } 00078 00079 protected: 00080 /*virtual void handleLog( ZMexception & x, const int limit );*/ 00081 ZMexAction standardHandling( const ZMexception & x, bool willThrow ); 00082 00083 private: 00084 const std::string name_; 00085 00086 }; // ZMexHandlerBehavior 00087 00088 00089 00090 //************ 00091 // 00092 // ZMexHandler 00093 // 00094 //************ 00095 00096 class ZMexHandler : public ZMhandleTo< ZMexHandlerBehavior > { 00097 // Handler interface 00098 00099 public: 00100 ZMexHandler( 00101 const ZMexHandlerBehavior & behaviorWanted 00102 ) : 00103 ZMhandleTo<ZMexHandlerBehavior>( behaviorWanted ) 00104 { } 00105 00106 virtual ~ZMexHandler() { } 00107 00108 std::string name() const { 00109 return rep_->name(); 00110 } 00111 00112 virtual ZMexAction takeCareOf( const ZMexception & x ) { 00113 return rep_->takeCareOf(x); 00114 } 00115 00116 int setLogLimit( ZMexSeverity s, int limit ) { 00117 int lim = ZMexSeverityLimit[ s ]; 00118 ZMexSeverityLimit[ s ] = limit; 00119 return lim; 00120 } 00121 00122 }; // ZMexHandler 00123 00124 00125 00126 //**************** 00127 // 00128 // ZMexThrowAlways 00129 // 00130 //**************** 00131 00132 class ZMexThrowAlways : public ZMexHandlerBehavior { 00133 00134 public: 00135 ZMexThrowAlways() : ZMexHandlerBehavior( "ZMexThrowAlways" ) { } 00136 virtual ZMexThrowAlways * clone() const; 00137 virtual ZMexAction takeCareOf( const ZMexception & x ); 00138 }; 00139 00140 00141 //**************** 00142 // 00143 // ZMexThrowErrors 00144 // 00145 //**************** 00146 00147 class ZMexThrowErrors : public ZMexHandlerBehavior { 00148 00149 public: 00150 ZMexThrowErrors() : ZMexHandlerBehavior( "ZMexThrowErrors" ) { } 00151 virtual ZMexThrowErrors * clone() const; 00152 virtual ZMexAction takeCareOf( const ZMexception & x ); 00153 }; 00154 00155 00156 //***************** 00157 // 00158 // ZMexIgnoreAlways 00159 // 00160 //***************** 00161 00162 class ZMexIgnoreAlways : public ZMexHandlerBehavior { 00163 00164 public: 00165 ZMexIgnoreAlways() : ZMexHandlerBehavior( "ZMexIgnoreAlways" ) { } 00166 virtual ZMexIgnoreAlways * clone() const; 00167 virtual ZMexAction takeCareOf( const ZMexception & x ); 00168 }; 00169 00170 00171 //***************** 00172 // 00173 // ZMexIgnoreNextN 00174 // 00175 //***************** 00176 00177 class ZMexIgnoreNextN : public ZMexHandlerBehavior { 00178 00179 public: 00180 ZMexIgnoreNextN( int n ) : 00181 ZMexHandlerBehavior( "ZMexIgnoreNextN" ), 00182 countDown_( n ) 00183 { } 00184 virtual ZMexIgnoreNextN * clone() const; 00185 virtual ZMexAction takeCareOf( const ZMexception & x ); 00186 00187 private: 00188 int countDown_; 00189 }; 00190 00191 00192 //****************** 00193 // 00194 // ZMexHandleViaParent 00195 // 00196 //****************** 00197 00198 class ZMexHandleViaParent : public ZMexHandlerBehavior { 00199 public: 00200 ZMexHandleViaParent() : ZMexHandlerBehavior( "" ) { } 00201 virtual ZMexHandleViaParent * clone() const; 00202 virtual ZMexAction takeCareOf( const ZMexception & x ); 00203 }; 00204 00205 00206 } // namespace zmex 00207 00208 00209 #define ZMEXHANDLER_ICC 00210 #include "CLHEP/Exceptions/ZMexHandler.icc" 00211 #undef ZMEXHANDLER_ICC 00212 00213 00214 #endif // ZMEXHANDLER_H