CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
ZMerrno.h
Go to the documentation of this file.
1#ifndef ZMERRNO_H
2#define ZMERRNO_H
3
4
5// ----------------------------------------------------------------------
6//
7// ZMerrno.h - declaration of ZMerrno and its ZMerrnoList class
8//
9// Declares the following, which are defined in ZMerrno.cc:
10// ZMerrnoList();
11// unsigned int setMax(unsigned int max_number);
12// void write(ZMexception& x);
13// string name(unsigned int k = 0) const;
14// const ZMexception* get(unsigned int k=0) const;
15// void clear();
16// void erase();
17// discard();
18//
19// Defined in ZMerrno.icc:
20// int size() const;
21// int count() const;
22// int countSinceCleared() const;
23//
24// Revision History:
25// 970916 WEB Updated per code review
26// 970917 WEB Updated per code review 2
27// 970918 PGC Change deque from Exception object to Exception
28// pointer to keep polymorphism.
29// 971112 WEB Updated for conformance to standard and the zoom
30// compatability headers
31// 980615 WEB Added namespace support
32// 980728 WEB Added ZMerrnoList destructor
33// 000217 WEB Improve C++ standard compliance
34// 000503 WEB Avoid global using
35// 011030 MF Changed return type of size() to unsigned int
36// to avoid conversion warnings
37// 031105 LG Get rid of all ZMutility references
38//
39// ----------------------------------------------------------------------
40
41#ifndef STRING_INCLUDED
42 #define STRING_INCLUDED
43 #include <string>
44#endif
45
46#ifndef DEQUE_INCLUDED
47 #define DEQUE_INCLUDED
48 #include <deque>
49#endif
50
51
52namespace zmex {
53
54
55class ZMexception;
56
58
59public:
60
62 // Constructor of list.
63
65 // Destructor of list.
66
67 unsigned int setMax( unsigned int limit );
68 // Set the maximum number of exceptions to be kept in the ZMerrnoList.
69 // We prohibit unlimited size because each exception kept
70 // may represent a memory leak of at least sizeof(ZMexception). You
71 // really do want a circular buffer; in Unix the size of that buffer is 1.
72 // Zero completely disables the ZMerrno mechanism and clears out and
73 // deletes the exceptions on the list.
74
75 void write( const ZMexception & x );
76 // Copy an exception onto ZMerrno at the "back" of the deque
77
78 int countSinceCleared() const;
79 // Returns the number of exceptions since last cleared
80
81 std::string name( unsigned int k = 0 ) const;
82 // Obtain the mnemonic name of the latest-but-k exception on ZMerrno.
83 // Thus name()gets the name of the latest exception.
84
85 const ZMexception* get( unsigned int k = 0 ) const;
86 // Obtain a pointer to the exception for the latest-but-k exception
87 // on ZMerrno. Thus get() obtains a const pointer to the latest exception.
88 // Allows perusal of things like the message and the logger
89 // and handler used when the exception was encountered. Should be
90 // checked for 0 since ZMerrno may not go back as far as requested.
91
92 void clear();
93 // Zero out the countSinceCleared.
94
95 void erase();
96 // Remove the top entry, restoring the top (latest entry) to the
97 // previous entry (if any). For instance, if you have a loop in which
98 // some known ignorable happening places a value on the ZMerrnoList, you
99 // can erase each one so as not to wipe out the history for others.
100
101 int count() const;
102 // Return the number of exceptions ever placed on the ZMerrnoList
103 // via ZMerrnoList::write().
104
105 unsigned int size() const;
106 // Return the number of entries currently on the stack.
107
108private:
109
110 std::deque< const ZMexception * > errors_;
111
112 unsigned int max_;
113 static const int ZMERRNO_LENGTH = 100;
114 // Default maximum number of entries on the stack
115
116 int count_;
117 int countSinceCleared_;
118
119}; // ZMerrnoList
120
121
122extern ZMerrnoList ZMerrno;
123
124
125} // namespace zmex
126
127
128#define ZMERRNO_ICC
129#include "CLHEP/Exceptions/ZMerrno.icc"
130#undef ZMERRNO_ICC
131
132
133#endif // ZMERRNO_H
unsigned int setMax(unsigned int limit)
Definition: ZMerrno.cc:147
unsigned int size() const
void write(const ZMexception &x)
Definition: ZMerrno.cc:67
int countSinceCleared() const
int count() const
const ZMexception * get(unsigned int k=0) const
Definition: ZMerrno.cc:95
std::string name(unsigned int k=0) const
Definition: ZMerrno.cc:113
Definition: ZMerrno.h:52
ZMerrnoList ZMerrno
Definition: ZMerrno.cc:40