CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 #ifndef ZMERRNO_H 00002 #define ZMERRNO_H 00003 00004 00005 // ---------------------------------------------------------------------- 00006 // 00007 // ZMerrno.h - declaration of ZMerrno and its ZMerrnoList class 00008 // 00009 // Declares the following, which are defined in ZMerrno.cc: 00010 // ZMerrnoList(); 00011 // unsigned int setMax(unsigned int max_number); 00012 // void write(ZMexception& x); 00013 // string name(unsigned int k = 0) const; 00014 // const ZMexception* get(unsigned int k=0) const; 00015 // void clear(); 00016 // void erase(); 00017 // discard(); 00018 // 00019 // Defined in ZMerrno.icc: 00020 // int size() const; 00021 // int count() const; 00022 // int countSinceCleared() const; 00023 // 00024 // Revision History: 00025 // 970916 WEB Updated per code review 00026 // 970917 WEB Updated per code review 2 00027 // 970918 PGC Change deque from Exception object to Exception 00028 // pointer to keep polymorphism. 00029 // 971112 WEB Updated for conformance to standard and the zoom 00030 // compatability headers 00031 // 980615 WEB Added namespace support 00032 // 980728 WEB Added ZMerrnoList destructor 00033 // 000217 WEB Improve C++ standard compliance 00034 // 000503 WEB Avoid global using 00035 // 011030 MF Changed return type of size() to unsigned int 00036 // to avoid conversion warnings 00037 // 031105 LG Get rid of all ZMutility references 00038 // 00039 // ---------------------------------------------------------------------- 00040 00041 #ifndef STRING_INCLUDED 00042 #define STRING_INCLUDED 00043 #include <string> 00044 #endif 00045 00046 #ifndef DEQUE_INCLUDED 00047 #define DEQUE_INCLUDED 00048 #include <deque> 00049 #endif 00050 00051 00052 namespace zmex { 00053 00054 00055 class ZMexception; 00056 00057 class ZMerrnoList { 00058 00059 public: 00060 00061 ZMerrnoList(); 00062 // Constructor of list. 00063 00064 ~ZMerrnoList(); 00065 // Destructor of list. 00066 00067 unsigned int setMax( unsigned int limit ); 00068 // Set the maximum number of exceptions to be kept in the ZMerrnoList. 00069 // We prohibit unlimited size because each exception kept 00070 // may represent a memory leak of at least sizeof(ZMexception). You 00071 // really do want a circular buffer; in Unix the size of that buffer is 1. 00072 // Zero completely disables the ZMerrno mechanism and clears out and 00073 // deletes the exceptions on the list. 00074 00075 void write( const ZMexception & x ); 00076 // Copy an exception onto ZMerrno at the "back" of the deque 00077 00078 int countSinceCleared() const; 00079 // Returns the number of exceptions since last cleared 00080 00081 std::string name( unsigned int k = 0 ) const; 00082 // Obtain the mnemonic name of the latest-but-k exception on ZMerrno. 00083 // Thus name()gets the name of the latest exception. 00084 00085 const ZMexception* get( unsigned int k = 0 ) const; 00086 // Obtain a pointer to the exception for the latest-but-k exception 00087 // on ZMerrno. Thus get() obtains a const pointer to the latest exception. 00088 // Allows perusal of things like the message and the logger 00089 // and handler used when the exception was encountered. Should be 00090 // checked for 0 since ZMerrno may not go back as far as requested. 00091 00092 void clear(); 00093 // Zero out the countSinceCleared. 00094 00095 void erase(); 00096 // Remove the top entry, restoring the top (latest entry) to the 00097 // previous entry (if any). For instance, if you have a loop in which 00098 // some known ignorable happening places a value on the ZMerrnoList, you 00099 // can erase each one so as not to wipe out the history for others. 00100 00101 int count() const; 00102 // Return the number of exceptions ever placed on the ZMerrnoList 00103 // via ZMerrnoList::write(). 00104 00105 unsigned int size() const; 00106 // Return the number of entries currently on the stack. 00107 00108 private: 00109 00110 std::deque< const ZMexception * > errors_; 00111 00112 unsigned int max_; 00113 enum { ZMERRNO_LENGTH = 100 }; 00114 // Default maximum number of entries on the stack 00115 00116 int count_; 00117 int countSinceCleared_; 00118 00119 }; // ZMerrnoList 00120 00121 00122 extern ZMerrnoList ZMerrno; 00123 00124 00125 } // namespace zmex 00126 00127 00128 #define ZMERRNO_ICC 00129 #include "CLHEP/Exceptions/ZMerrno.icc" 00130 #undef ZMERRNO_ICC 00131 00132 00133 #endif // ZMERRNO_H