|
||||
File indexing completed on 2025-01-18 09:54:33
0001 #ifndef ZMTHROW_H 0002 #define ZMTHROW_H 0003 0004 // ---------------------------------------------------------------------- 0005 // 0006 // ZMthrow.h - macro definition for the ZMthrow macro, tand function 0007 // declarations for ZMthrow_from() and ZMthrow_(). 0008 // 0009 // ZMthrow(x) calls ZMthrow_ but adds on the line and file arguments. 0010 // It either throws or not, depending on the return value of ZMthrow_. 0011 // 0012 // ZMthrow_from(x,line,file) calls ZMthrow_ using the supplied line and file 0013 // file arguments. Again, it either throws or not, depending on the return 0014 // value of ZMthrow_. 0015 // 0016 // ZMthrow_(), should not be used directly by user code, but is defined in 0017 // ZMthrow.cc for use by the ZMthrow macro and by ZMthrow_from. 0018 // 0019 // NOTE -- ZMthrow() and ZMthrow_from() are NOT in namespace zmex:: 0020 // ZMthrow() is NOT namespace qualified; it is a macro. 0021 // ZMthrow_from() is NOT namespace qualified; it is a macro. 0022 // 0023 // Revision History 0024 // 970910 MF Initial version 0025 // 970916 WEB Update per code review 0026 // 970917 WEB Update per code review 2 0027 // 970918 PGC Replace monolitic if by do while loop 0028 // 971113 WEB Correct minor typo 0029 // 980615 WEB Add namespace support 0030 // 000218 WEB Replace NOTHROW by DEFECT_NO_EXCEPTIONS for 0031 // ISOcxx compatibility 0032 // 000512 WEB DEBUG corrections; remove useless reference in 0033 // NO_EXCEPTIONS definition 0034 // 010409 MF ZMthrow_from() 0035 // 010413 MF Include ZMenvironment and make other changes to 0036 // make sure namespaces are treated properly. 0037 // 031105 LG Get rid of all ZMutility references 0038 // 0039 // ---------------------------------------------------------------------- 0040 0041 #ifndef ZMEXACTION_H 0042 #include "CLHEP/Exceptions/ZMexAction.h" 0043 #endif 0044 0045 #include <stdlib.h> // for abort() 0046 #include <string> 0047 0048 /* DEBUG #include <iostream> // for cerr */ 0049 0050 0051 namespace zmex { 0052 0053 0054 class ZMexception; 0055 0056 0057 //******************* 0058 // 0059 // ZMthrow_from macro 0060 // 0061 //******************* 0062 0063 0064 #ifdef DEFECT_NO_EXCEPTIONS 0065 0066 #define ZMthrow_from(userExcept, line, file ) \ 0067 do { \ 0068 if ( zmex::ZMthrow_( userExcept, line, file ) == \ 0069 zmex::ZMexThrowIt ) { \ 0070 abort(); } \ 0071 } while (false) \ 0072 0073 #else 0074 0075 #define ZMthrow_from(userExcept, line, file ) \ 0076 do { \ 0077 try { throw userExcept; } \ 0078 catch ( const zmex::ZMexception & x ) { \ 0079 if ( zmex::ZMthrow_( x, line, file ) == \ 0080 zmex::ZMexThrowIt ) { \ 0081 throw; \ 0082 } \ 0083 } \ 0084 } while (false) \ 0085 0086 #endif // NOTHROW 0087 0088 // 0089 // End of the ZMthrow_from macro, which should NOT end with a semicolon. 0090 0091 //************** 0092 // 0093 // ZMthrow macro 0094 // 0095 //************** 0096 0097 #define ZMthrow(userExcept) ZMthrow_from(userExcept, __LINE__, __FILE__) 0098 0099 // 0100 // End of the ZMthrow macro, which should NOT end with a semicolon. 0101 0102 // NOTE - This is a macro. It has to be a monolithic statement so that a 0103 // construct like 0104 // if (xxx) ZMthrow(ZMxAbc); else dowhatever; 0105 // works. Since the content CANNOT therefore be in a block, we use 0106 // a do-while loop that will be executed exactly once. 0107 0108 //*********** 0109 // 0110 // ZMthrow_() 0111 // 0112 //*********** 0113 0114 ZMexAction ZMthrow_( 0115 const ZMexception & userException 0116 , int lineNum 0117 , const char fileName[] 0118 ); 0119 0120 } // namespace zmex 0121 0122 0123 0124 #endif // ZMTHROW_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |