1 | // $Id: EsafMsgSource.hh 2804 2008-10-09 12:10:06Z biktem $ |
---|
2 | // Author: M. Pallavicini Sep, 24 2004 |
---|
3 | |
---|
4 | /***************************************************************************** |
---|
5 | * ESAF: Euso Simulation and Analysis Framework * |
---|
6 | * * |
---|
7 | * Id: EsafMsgSource * |
---|
8 | * Package: Base * |
---|
9 | * Coordinator: Marco.Pallavicini * |
---|
10 | * * |
---|
11 | *****************************************************************************/ |
---|
12 | |
---|
13 | #ifndef __ESAFMSGSOURCE_HH_ |
---|
14 | #define __ESAFMSGSOURCE_HH_ |
---|
15 | |
---|
16 | #include <string> |
---|
17 | #include "euso.hh" |
---|
18 | #include "EsafMsg.hh" |
---|
19 | |
---|
20 | //////////////////////////////////////////////////////////////////////////////// |
---|
21 | // // |
---|
22 | // EsafMsgSource // |
---|
23 | // // |
---|
24 | // ESAF Message Source // |
---|
25 | // // |
---|
26 | //////////////////////////////////////////////////////////////////////////////// |
---|
27 | |
---|
28 | class EsafMsgSource { |
---|
29 | protected: |
---|
30 | |
---|
31 | EsafMsgSource(); |
---|
32 | // default ctor |
---|
33 | |
---|
34 | EsafMsgSource(const EsafMsgSource& ); |
---|
35 | |
---|
36 | public: |
---|
37 | virtual ~EsafMsgSource() {} |
---|
38 | // dtor |
---|
39 | |
---|
40 | EsafMsg& Msg( EsafMsg::MsgSeverity ) const; |
---|
41 | // prepare message and returns it for writing |
---|
42 | |
---|
43 | void MsgForm( EsafMsg::MsgSeverity, const char *fmt, ...) const; |
---|
44 | // void MsgForm( EsafMsg::MsgSeverity, const char *fmt) const; |
---|
45 | // prepare and send a message with printf syntax |
---|
46 | |
---|
47 | inline void Dispatch() const { fMsg.Dispatch(); } |
---|
48 | // dispatch message |
---|
49 | |
---|
50 | inline void FatalError( const string& ) const; |
---|
51 | |
---|
52 | inline void SetSender(const char* s) {fMsg.SetSender(s);} |
---|
53 | // |
---|
54 | |
---|
55 | private: |
---|
56 | |
---|
57 | mutable EsafMsg fMsg; |
---|
58 | // the message |
---|
59 | |
---|
60 | public: |
---|
61 | ClassDef(EsafMsgSource,0) |
---|
62 | }; |
---|
63 | |
---|
64 | |
---|
65 | inline void EsafMsgSource::FatalError( const string& errmsg ) const { |
---|
66 | Msg(EsafMsg::Panic) << errmsg << MsgDispatch; |
---|
67 | } |
---|
68 | |
---|
69 | #endif /* __ESAFMSGSOURCE_HH_ */ |
---|