// $Id: EsafMsg.hh,v 1.10 2005/10/23 22:27:35 thea Exp $ // M. Pallavicini created Sep, 24 2004 /***************************************************************************** * ESAF: Euso Simulation and Analysis Framework * * * * Id: EsafMsg * * Package: Base * * Coordinator: Marco.Pallavicini * * * *****************************************************************************/ #ifndef __ESAFMSG_HH__ #define __ESAFMSG_HH__ #include "euso.hh" #include #include // #include // using namespace std; // // The following definitions are needed to compile EsafMsg in the Lyon CC gcc // 2.96 environment, where ostrstream and strstreambase are not defined. // #if ( __GNUC__ < 3 ) #ifndef __MAKECINT__ typedef ostringstream ostrstream; typedef stringstreambase strstreambase; #endif /*__MAKECINT__*/ #endif //////////////////////////////////////////////////////////////////////////////// // // // EsafMsg // // // // ESAF Message // // // //////////////////////////////////////////////////////////////////////////////// class EsafMsg : public ostringstream { public: enum MsgSeverity { Debug=1, Info=2, Warning=3, Panic=4, None=100 }; EsafMsg(); // constructor EsafMsg( const EsafMsg& ); // copy constructor EsafMsg(MsgSeverity, const string&, const string&); virtual ~EsafMsg(); void Copy( EsafMsg& ) const; EsafMsg& operator=(const EsafMsg& ); inline void SetSeverity(MsgSeverity svr) { fSeverity = svr; } inline void SetSender(const string& snd) { fSender = snd; } inline void SetText(const string& txt) { str(txt); } inline MsgSeverity GetSeverity() const { return fSeverity;} inline const string GetSender() const { return fSender; } inline const string GetText() const { return str(); } void Clear(); void Dispatch(); void Flush(); // Functions that used for display counting progress void Count(); inline void SetProgress(int progress = -1) {fProgress = progress;} inline Int_t GetProgress() const {return fProgress;} private: Int_t fProgress; // Counting status MsgSeverity fSeverity; string fSender; ClassDef(EsafMsg,0) }; inline std::ostream& MsgDispatch(ostream& os) { // function to allow syntax: msg << "bla bla" << MsgDispatch; (dynamic_cast(os)).Dispatch(); return os; } inline std::ostream& MsgFlush(ostream& os) { // function to allow syntax: msg << "bla bla" << MsgDispatch; (dynamic_cast(os)).Flush(); return os; } // Process counting inline std::ostream& MsgCount(ostream& os) { // Before using this function use msg.SetProgress(fProgress) // function to allow syntax: msg << "Processing:" << MsgCount; (dynamic_cast(os)).Count(); return os; } #endif /* __ESAFMSG_HH__ */