CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
ZMexHandler.h
Go to the documentation of this file.
1#ifndef ZMEXHANDLER_H
2#define ZMEXHANDLER_H
3
4
5// ----------------------------------------------------------------------
6//
7// ZMexHandler.h - interface class declarations for the ZOOM Exception
8// Handler base class and the basic handlers:
9// ZMexThrowAlways
10// ZMexIgnoreAlways
11// ZMexThrowErrors
12// ZMexIgnoreNextN
13// ZMexHandleViaParent
14// These can be used as examples if custom handlers are desired.
15//
16// Revision History:
17// 970909 MF Initial version
18// 970916 WEB Updated per code review
19// 970917 WEB Updated per code review 2
20// 970923 WEB Updated per code review 4
21// 971008 WEB ZMutility is the new name for the Utility package
22// 971112 WEB Updated for conformance to standard and the zoom
23// compatability headers
24// 980615 WEB Added namespace support
25// 990318 MF Modified intializer list orders to avoid warnings
26// 000217 WEB Improve C++ standards compliance
27// 000503 WEB Avoid global using
28// 031105 LG Get rid of all ZMutility references
29//
30// ----------------------------------------------------------------------
31
32#ifndef STRING_INCLUDED
33 #define STRING_INCLUDED
34 #include <string>
35#endif
36
37#ifndef ZMHANDLETO_H
38 #include "CLHEP/RefCount/ZMhandleTo.h"
39#endif
40
41#ifndef ZMEXSEVERITY_H
42 #include "CLHEP/Exceptions/ZMexSeverity.h"
43#endif
44
45#ifndef ZMEXACTION_H
46 #include "CLHEP/Exceptions/ZMexAction.h"
47#endif
48
49
50namespace zmex {
51
52
53class ZMexception;
54
55
56//********************
57//
58// ZMexHandlerBehavior
59//
60//********************
61
63 // Handler behavior interface definition
64
65public:
67 const std::string aname = "ZMexHandlerBehavior"
68 ) : name_( aname ) { }
69
71
72 virtual ZMexHandlerBehavior * clone() const {
73 return new ZMexHandlerBehavior( *this );
74 }
75
76 virtual std::string name() const { return name_; }
77 virtual ZMexAction takeCareOf( const ZMexception & ) { return ZMexThrowIt; }
78
79protected:
80 /*virtual void handleLog( ZMexception & x, const int limit );*/
81 ZMexAction standardHandling( const ZMexception & x, bool willThrow );
82
83private:
84 const std::string name_;
85
86}; // ZMexHandlerBehavior
87
88
89
90//************
91//
92// ZMexHandler
93//
94//************
95
96class ZMexHandler : public ZMhandleTo< ZMexHandlerBehavior > {
97 // Handler interface
98
99public:
101 const ZMexHandlerBehavior & behaviorWanted
102 ) :
103 ZMhandleTo<ZMexHandlerBehavior>( behaviorWanted )
104 { }
105
106 virtual ~ZMexHandler();
107
108 std::string name() const {
109 return rep_->name();
110 }
111
112 virtual ZMexAction takeCareOf( const ZMexception & x ) {
113 return rep_->takeCareOf(x);
114 }
115
116 int setLogLimit( ZMexSeverity s, int limit ) {
117 int lim = ZMexSeverityLimit[ s ];
118 ZMexSeverityLimit[ s ] = limit;
119 return lim;
120 }
121
122}; // ZMexHandler
123
124
125
126//****************
127//
128// ZMexThrowAlways
129//
130//****************
131
133
134public:
135 ZMexThrowAlways() : ZMexHandlerBehavior( "ZMexThrowAlways" ) { }
136 virtual ZMexThrowAlways * clone() const;
137 virtual ZMexAction takeCareOf( const ZMexception & x );
138};
139
140
141//****************
142//
143// ZMexThrowErrors
144//
145//****************
146
148
149public:
150 ZMexThrowErrors() : ZMexHandlerBehavior( "ZMexThrowErrors" ) { }
151 virtual ZMexThrowErrors * clone() const;
152 virtual ZMexAction takeCareOf( const ZMexception & x );
153};
154
155
156//*****************
157//
158// ZMexIgnoreAlways
159//
160//*****************
161
163
164public:
165 ZMexIgnoreAlways() : ZMexHandlerBehavior( "ZMexIgnoreAlways" ) { }
166 virtual ZMexIgnoreAlways * clone() const;
167 virtual ZMexAction takeCareOf( const ZMexception & x );
168};
169
170
171//*****************
172//
173// ZMexIgnoreNextN
174//
175//*****************
176
178
179public:
181 ZMexHandlerBehavior( "ZMexIgnoreNextN" ),
182 countDown_( n )
183 { }
184 virtual ZMexIgnoreNextN * clone() const;
185 virtual ZMexAction takeCareOf( const ZMexception & x );
186
187private:
188 int countDown_;
189};
190
191
192//******************
193//
194// ZMexHandleViaParent
195//
196//******************
197
199public:
201 virtual ZMexHandleViaParent * clone() const;
202 virtual ZMexAction takeCareOf( const ZMexception & x );
203};
204
205
206} // namespace zmex
207
208
209#define ZMEXHANDLER_ICC
210#include "CLHEP/Exceptions/ZMexHandler.icc"
211#undef ZMEXHANDLER_ICC
212
213
214#endif // ZMEXHANDLER_H
ZMexHandlerBehavior * rep_
Definition: ZMhandleTo.h:39
virtual ZMexHandleViaParent * clone() const
virtual ZMexAction takeCareOf(const ZMexception &x)
ZMexAction standardHandling(const ZMexception &x, bool willThrow)
Definition: ZMexHandler.cc:46
virtual ZMexAction takeCareOf(const ZMexception &)
Definition: ZMexHandler.h:77
virtual ZMexHandlerBehavior * clone() const
Definition: ZMexHandler.h:72
ZMexHandlerBehavior(const std::string aname="ZMexHandlerBehavior")
Definition: ZMexHandler.h:66
virtual std::string name() const
Definition: ZMexHandler.h:76
virtual ~ZMexHandlerBehavior()
Definition: ZMexHandler.h:70
virtual ZMexAction takeCareOf(const ZMexception &x)
Definition: ZMexHandler.h:112
std::string name() const
Definition: ZMexHandler.h:108
int setLogLimit(ZMexSeverity s, int limit)
Definition: ZMexHandler.h:116
virtual ~ZMexHandler()
Definition: ZMexHandler.cc:30
ZMexHandler(const ZMexHandlerBehavior &behaviorWanted)
Definition: ZMexHandler.h:100
virtual ZMexIgnoreAlways * clone() const
virtual ZMexAction takeCareOf(const ZMexception &x)
virtual ZMexAction takeCareOf(const ZMexception &x)
virtual ZMexIgnoreNextN * clone() const
virtual ZMexThrowAlways * clone() const
virtual ZMexAction takeCareOf(const ZMexception &x)
virtual ZMexThrowErrors * clone() const
virtual ZMexAction takeCareOf(const ZMexception &x)
Definition: ZMexHandler.cc:70
Definition: ZMerrno.h:52
int ZMexSeverityLimit[ZMexSEVERITYenumLAST]
Definition: ZMexSeverity.cc:45
ZMexAction
Definition: ZMexAction.h:20
@ ZMexThrowIt
Definition: ZMexAction.h:20
ZMexSeverity
Definition: ZMexSeverity.h:32