CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
Exceptions
CLHEP
Exceptions
CLHEP/Exceptions/ZMexLogger.h
Go to the documentation of this file.
1
#ifndef ZMEXLOGGER_H
2
#define ZMEXLOGGER_H
3
4
5
// ----------------------------------------------------------------------
6
//
7
// ZMexLogger.h - class declaration for the ZOOM Exception Logger base class
8
// and the basic logger ZMexLogger, the base class
9
// ZMexLogBehavior, and behaviors supplied with the package:
10
// ZMexLogNever
11
// ZMexLogAlways
12
// ZMexLogTwice
13
// ZMexLogViaParent
14
// ZMexValidationStyle
15
//
16
// Revision History:
17
// 970917 WEB Updated per code review 2
18
// 970919 WEB Updated per code review 4
19
// 971007 WEB Removed limiting logger; all loggers now
20
// optionally limit by exception severity
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
// 971211 WEB Updated per code walkthrough
25
// 971215 WEB Removed unused 2nd parm to ZMexLogger constructor
26
// 980615 WEB Added namespace support
27
// 010410 MF Added ZMexValidationStyle
28
//
29
// ----------------------------------------------------------------------
30
31
#ifndef STRING_INCLUDED
32
#define STRING_INCLUDED
33
#include <string>
34
#endif
35
36
#include <iostream>
37
38
#ifndef ZMEXLOGRESULT_H
39
#include "
CLHEP/Exceptions/ZMexLogResult.h
"
40
#endif
41
42
#ifndef ZMHANDLETO_H
43
#include "CLHEP/RefCount/ZMhandleTo.h"
44
#endif
45
46
47
// ----------------------------------------------------------------------
48
49
50
namespace
zmex {
51
52
53
// ----------------------------------------------------------------------
54
55
56
class
ZMexLogger;
57
class
ZMexception;
58
59
60
// ----------------------------------------------------------------------
61
62
63
// ---------------
64
// ZMexLogBehavior
65
// ---------------
66
67
class
ZMexLogBehavior
{
68
// Logger behavior interface class
69
70
public
:
71
72
ZMexLogBehavior
();
73
// Construct this behavior
74
75
virtual
~ZMexLogBehavior
();
76
// Destroy this behavior
77
78
virtual
ZMexLogBehavior
*
clone
()
const
;
79
// Duplicate this logger object
80
81
virtual
ZMexLogResult
emit
(
const
ZMexception
& x );
82
// Extract the formatted message, then
83
// carry out this logger's basic logging behavior
84
85
virtual
ZMexLogResult
emit
(
const
std::string & s );
86
// Carry out this logger's basic logging behavior
87
// Do nothing with s; this base class function ought never be called
88
89
virtual
bool
isTimeDesired
()
const
;
90
virtual
bool
isFilePathDesired
()
const
;
91
92
};
// ZMexLogBehavior
93
94
95
96
// ------------
97
// ZMexLogNever
98
// ------------
99
100
class
ZMexLogNever
:
public
ZMexLogBehavior
{
101
102
public
:
103
104
ZMexLogNever
();
105
// Construct this behavior
106
107
virtual
~ZMexLogNever
();
108
// Destroy this behavior
109
110
virtual
ZMexLogResult
emit
(
const
ZMexception
& x );
111
// Extract the formatted message, then
112
// carry out this logger's basic logging behavior
113
114
virtual
ZMexLogNever
*
clone
()
const
;
115
// Duplicate this logger object
116
117
virtual
ZMexLogResult
emit
(
const
std::string & s );
118
// Carry out this logger's basic logging behavior: do nothing with s
119
120
};
// ZMexLogNever
121
122
123
// -------------
124
// ZMexLogAlways
125
// -------------
126
127
class
ZMexLogAlways
:
public
ZMexLogBehavior
{
128
129
public
:
130
131
ZMexLogAlways
();
132
ZMexLogAlways
( std::ostream & os );
133
// Construct this behavior with given destination
134
135
virtual
~ZMexLogAlways
();
136
// Destroy this behavior
137
138
virtual
ZMexLogAlways
*
clone
()
const
;
139
// Duplicate this logger object
140
141
virtual
ZMexLogResult
emit
(
const
ZMexception
& x );
142
// Extract the formatted message, then
143
// carry out this logger's basic logging behavior
144
145
virtual
ZMexLogResult
emit
(
const
std::string & s );
146
// Carry out this logger's basic logging behavior: myOs << s
147
148
private
:
149
150
std::ostream & myOs;
151
// This logger's destination for messages to be logged
152
153
};
// ZMexLogAlways
154
155
156
// -------------
157
// ZMexLogTwice
158
// -------------
159
160
class
ZMexLogTwice
:
public
ZMexLogBehavior
{
161
162
public
:
163
164
ZMexLogTwice
( std::ostream & os1 );
165
ZMexLogTwice
( std::ostream & os1, std::ostream & os2 );
166
// Construct this behavior with given destinations
167
168
virtual
~ZMexLogTwice
();
169
// Destroy this behavior
170
171
virtual
ZMexLogTwice
*
clone
()
const
;
172
// Duplicate this logger object
173
174
virtual
ZMexLogResult
emit
(
const
ZMexception
& x );
175
// Extract the formatted message, then
176
// carry out this logger's basic logging behavior
177
178
virtual
ZMexLogResult
emit
(
const
std::string & s );
179
// Carry out this logger's basic logging behavior: os_ << s, os2_ << s
180
181
private
:
182
183
std::ostream & myOs1;
184
std::ostream & myOs2;
185
186
};
// ZMexLogTwice
187
188
189
// ----------------
190
// ZMexLogViaParent
191
// ----------------
192
193
class
ZMexLogViaParent
:
public
ZMexLogBehavior
{
194
195
public
:
196
197
ZMexLogViaParent
();
198
// Construct this behavior
199
200
virtual
~ZMexLogViaParent
();
201
// Destroy this behavior
202
203
virtual
ZMexLogViaParent
*
clone
()
const
;
204
// Duplicate this logger object
205
206
virtual
ZMexLogResult
emit
(
const
ZMexception
& x );
207
// Extract the formatted message, then
208
// carry out this logger's basic logging behavior
209
210
virtual
ZMexLogResult
emit
(
const
std::string & s );
211
// Carry out this logger's basic logging behavior: defer elsewhere
212
213
};
// ZMexLogViaParent
214
215
216
// -----------------
217
// ZMexValidationStyle
218
// -----------------
219
220
class
ZMexValidationStyle
:
public
ZMexLogBehavior
{
221
222
public
:
223
224
ZMexValidationStyle
();
225
ZMexValidationStyle
( std::ostream & os );
226
// Construct this behavior with given destination
227
228
virtual
~ZMexValidationStyle
();
229
// Destroy this behavior
230
231
virtual
ZMexValidationStyle
*
clone
()
const
;
232
// Duplicate this logger object
233
234
virtual
ZMexLogResult
emit
(
const
ZMexception
& x );
235
// Extract the formatted message, then
236
// carry out this logger's basic logging behavior
237
238
virtual
ZMexLogResult
emit
(
const
std::string & s );
239
// Carry out this logger's basic logging behavior: myOs << s
240
241
virtual
bool
isTimeDesired
()
const
;
242
virtual
bool
isFilePathDesired
()
const
;
243
244
private
:
245
246
std::ostream & myOs;
247
// This logger's destination for messages to be logged
248
249
};
// ZMexValidationStyle
250
251
//************
252
// ZMexLogger
253
//************
254
255
256
class
ZMexLogger
:
public
ZMhandleTo
< ZMexLogBehavior > {
257
// Class defining logger interface
258
259
public
:
260
261
ZMexLogger
(
const
ZMexLogBehavior
& desiredBehavior );
262
// Construct logger with specified behavior
263
264
~ZMexLogger
();
265
// Destroy logger with its behavior
266
267
ZMexLogResult
emit
(
const
ZMexception
& exc );
268
// Hand over the exception for formatting and log entry
269
270
ZMexLogResult
emit
(
const
std::string & message );
271
// Hand over the given string (or char*) for log entry
272
273
ZMexLogBehavior
*
control
();
274
// Grant access to the representation
275
// to permit calling specialized behavior functions
276
277
};
// ZMexLogger
278
279
280
// ----------------------------------------------------------------------
281
282
283
}
// namespace zmex
284
285
286
// ----------------------------------------------------------------------
287
288
289
#endif // ZMEXLOGGER_H
Generated on Mon May 6 2013 04:04:12 for CLHEP by
1.8.1.2