Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:46

0001 #ifndef __MSG_CONTROL_H__
0002 #define __MSG_CONTROL_H__
0003 
0004 #include "msg_profile.h"
0005 #include "event_io.h"
0006 #include <string.h>
0007 
0008 /** 
0009 Objects of the msg\_control class maintain the profiling information 
0010 for your messages. They add a few tokens to the output stream which can be
0011 parsed by the msg\_buffer's routines, which so learns about the profile. 
0012 Use it, for example, like this:
0013 \begin{verbatim}
0014   msg_control *mvd_warning = new msg_control(MSG_TYPE_CODEDEBUG, 
0015                          MSG_SOURCE_MVD, 
0016                          MSG_SEV_WARNING);
0017   COUT <<  *mvd_info    << " this is a info message from MVD" << endl;
0018 \end{verbatim}
0019 
0020 The mvd\_info's "<<" operator adds now the profiling information to the message,
0021 which is then parsed again and stripped off by our custom streambuf.
0022 
0023 If we do not have a custom streambuf, the msg\_control objects maintain silence.
0024 They have to be activated by one of our custom streambufs first.
0025 
0026 * @VERSION: 2.0
0027 * ejd add string for component source of message
0028 */
0029 
0030 class msg_control
0031 {
0032    friend class msg_buffer;
0033 
0034   friend OSTREAM& operator<< (OSTREAM& , msg_control &);
0035 
0036 protected:
0037 
0038   int msg_type;
0039   int msg_source;
0040   int msg_severity;
0041   int storedseverity;
0042   char * msg_sourcecomponent;
0043 
0044 
0045   int activate();
0046   int deactivate();
0047 
0048 public:
0049 
0050 
0051   msg_control(const int mtype = MSG_TYPE_DEFAULT
0052           , const int source = MSG_SOURCE_DEFAULT
0053           , const int severity = MSG_SEV_DEFAULT
0054           , const char *sourcecomponent = "ONLINE");
0055 
0056   virtual ~msg_control();
0057 
0058   virtual void set_severity(const int severity); 
0059   virtual int get_severity() const { return msg_severity;};
0060   virtual void reset_severity() {msg_severity = storedseverity; };
0061   // set the message source id
0062   virtual void set_source(const int source) {msg_source = source; };
0063   virtual int  get_source() const { return msg_source; };
0064   virtual void set_sourcecomponent(const char * msgsourcecomponent = "ONLINE");
0065   virtual const char * get_sourcecomponent(){ return msg_sourcecomponent; };
0066 
0067   static int xx_active;
0068 
0069 };
0070 
0071 #endif /* __MSG_CONTROL_H__ */