Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:33

0001 #ifndef ZMERRNO_H
0002 #define ZMERRNO_H
0003 
0004 
0005 // ----------------------------------------------------------------------
0006 //
0007 // ZMerrno.h - declaration of ZMerrno and its ZMerrnoList class
0008 //
0009 // Declares the following, which are defined in ZMerrno.cc:
0010 //   ZMerrnoList();
0011 //   unsigned int setMax(unsigned int max_number);
0012 //   void write(ZMexception& x);
0013 //   string name(unsigned int k = 0) const;
0014 //   const ZMexception* get(unsigned int k=0) const;
0015 //   void clear();
0016 //   void erase();
0017 //   discard();
0018 //
0019 // Defined in ZMerrno.icc:
0020 //   int size() const;
0021 //   int count() const;
0022 //   int countSinceCleared() const;
0023 //
0024 // Revision History:
0025 //  970916  WEB Updated per code review
0026 //  970917  WEB Updated per code review 2
0027 //      970918  PGC     Change deque from Exception object to Exception
0028 //                      pointer to keep polymorphism.
0029 //      971112  WEB Updated for conformance to standard and the zoom
0030 //          compatability headers
0031 //  980615  WEB Added namespace support
0032 //  980728  WEB Added ZMerrnoList destructor
0033 //  000217  WEB Improve C++ standard compliance
0034 //  000503  WEB Avoid global using
0035 //  011030  MF  Changed return type of size() to unsigned int 
0036 //          to avoid conversion warnings
0037 //  031105  LG  Get rid of all ZMutility references
0038 //
0039 // ----------------------------------------------------------------------
0040 
0041 #ifndef STRING_INCLUDED
0042   #define STRING_INCLUDED
0043   #include <string>
0044 #endif
0045 
0046 #ifndef DEQUE_INCLUDED
0047   #define DEQUE_INCLUDED
0048   #include <deque>
0049 #endif
0050 
0051 
0052 namespace zmex  {
0053 
0054 
0055 class ZMexception;
0056 
0057 class ZMerrnoList {
0058 
0059 public:
0060 
0061   ZMerrnoList();
0062     // Constructor of list.
0063 
0064   ~ZMerrnoList();
0065     // Destructor of list.
0066 
0067   unsigned int setMax( unsigned int limit );
0068     // Set the maximum number of exceptions to be kept in the ZMerrnoList.
0069     // We prohibit unlimited size because each exception kept
0070     // may represent a memory leak of at least sizeof(ZMexception).  You
0071     // really do want a circular buffer; in Unix the size of that buffer is 1.
0072     // Zero completely disables the ZMerrno mechanism and clears out and
0073     // deletes the exceptions on the list.
0074 
0075   void write( const ZMexception & x );
0076     // Copy an exception onto ZMerrno at the "back" of the deque
0077 
0078   int countSinceCleared() const;
0079     // Returns the number of exceptions since last cleared
0080 
0081   std::string name( unsigned int k = 0 ) const;
0082     // Obtain the mnemonic name of the latest-but-k exception on ZMerrno.
0083     // Thus name()gets the name of the latest exception.
0084 
0085   const ZMexception* get( unsigned int k = 0 ) const;
0086     // Obtain a pointer to the exception for the latest-but-k exception
0087     // on ZMerrno.  Thus get() obtains a const pointer to the latest exception.
0088     // Allows perusal of things like the message and the logger
0089     // and handler used when the exception was encountered.  Should be
0090     // checked for 0 since ZMerrno may not go back as far as requested.
0091 
0092   void clear();
0093     // Zero out the countSinceCleared.
0094 
0095   void erase();
0096     // Remove the top entry, restoring the top (latest entry) to the
0097     // previous entry (if any).  For instance, if you have a loop in which
0098     // some known ignorable happening places a value on the ZMerrnoList, you
0099     // can erase each one so as not to wipe out the history for others.
0100 
0101   int count() const;
0102     // Return the number of exceptions ever placed on the ZMerrnoList
0103     // via ZMerrnoList::write().
0104 
0105   unsigned int size() const;
0106     // Return the number of entries currently on the stack.
0107 
0108 private:
0109 
0110   std::deque< const ZMexception * > errors_;
0111 
0112   unsigned int max_;
0113   static const int ZMERRNO_LENGTH = 100;
0114     // Default maximum number of entries on the stack
0115 
0116   int count_;
0117   int countSinceCleared_;
0118 
0119 };  // ZMerrnoList
0120 
0121 
0122 extern ZMerrnoList ZMerrno;
0123 
0124 
0125 }  // namespace zmex
0126 
0127 
0128 #define ZMERRNO_ICC
0129 #include "CLHEP/Exceptions/ZMerrno.icc"
0130 #undef ZMERRNO_ICC
0131 
0132 
0133 #endif  // ZMERRNO_H