source: JEM-EUSO/esaf_cc_at_lal/packages/common/base/include/EsafMsg.hh @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 3.5 KB
Line 
1// $Id: EsafMsg.hh 2835 2009-07-16 03:22:42Z biktem $
2// M. Pallavicini created Sep, 24 2004
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: EsafMsg                                                              *
8 *  Package: Base                                                            *
9 *  Coordinator: Marco.Pallavicini                                           *
10 *                                                                           *
11 *****************************************************************************/
12
13#ifndef __ESAFMSG_HH__
14#define __ESAFMSG_HH__
15
16#include "euso.hh"
17#include <string>
18#include <sstream>
19#include <Varargs.h>
20
21// using namespace std;
22
23//
24// The following definitions are needed to compile EsafMsg in the Lyon CC gcc
25// 2.96 environment, where ostrstream and strstreambase are not defined.
26//
27
28#if ( __GNUC__ < 3 )
29#ifndef __MAKECINT__
30typedef ostringstream ostrstream;
31typedef stringstreambase strstreambase;
32#endif  /*__MAKECINT__*/
33#endif
34
35////////////////////////////////////////////////////////////////////////////////
36//                                                                            //
37// EsafMsg                                                                    //
38//                                                                            //
39// ESAF Message                                                               //
40//                                                                            //
41////////////////////////////////////////////////////////////////////////////////
42
43class EsafMsg : public ostringstream {
44public:
45
46    enum MsgSeverity { Debug=1, Info=2, Warning=3, Error=4, Exception=5, Panic=6, None=100 };
47
48    EsafMsg();
49    // constructor
50
51    EsafMsg( const EsafMsg& );
52    // copy constructor
53
54    EsafMsg(MsgSeverity, const string&, const string&);
55
56    virtual ~EsafMsg();
57
58    void Copy( EsafMsg& ) const;
59
60    EsafMsg& operator=(const EsafMsg& );
61
62    inline void SetSeverity(MsgSeverity svr) { fSeverity = svr; }
63    inline void SetSender(const string& snd) { fSender = snd; }
64    inline void SetText(const string& txt) { str(txt); }
65
66    inline MsgSeverity GetSeverity() const { return fSeverity;}
67    inline const string GetSender() const { return fSender; }
68    inline const string GetText() const { return str(); }
69
70    void Clear();
71    void Dispatch();
72    void Flush();
73
74    // Functions that used for display counting progress
75
76    void Count();
77    inline void SetProgress(int progress = -1) {fProgress = progress;}
78    inline Int_t GetProgress() const {return fProgress;}
79
80private:
81
82    Int_t fProgress;        // Counting status
83    MsgSeverity fSeverity;
84    string fSender;
85
86    ClassDef(EsafMsg,0)
87};
88
89inline std::ostream& MsgDispatch(ostream& os) {
90    // function to allow syntax:   msg << "bla bla" << MsgDispatch;
91    (dynamic_cast<EsafMsg&>(os)).Dispatch();
92    return os;
93}
94
95inline std::ostream& MsgFlush(ostream& os) {
96    // function to allow syntax:   msg << "bla bla" << MsgDispatch;
97    (dynamic_cast<EsafMsg&>(os)).Flush();
98    return os;
99}
100
101// Process counting
102
103inline std::ostream& MsgCount(ostream& os) {
104    // Before using this function use msg.SetProgress(fProgress)
105    // function to allow syntax:   msg << "Processing:" << MsgCount;
106    (dynamic_cast<EsafMsg&>(os)).Count();
107    return os;
108}
109
110#endif  /* __ESAFMSG_HH__ */
Note: See TracBrowser for help on using the repository browser.