All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Message.h
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/Message.h,v 1.5 2008/02/20 19:16:23 hmd Exp $
2 #ifndef GAUDIKERNEL_MESSAGE_H
3 #define GAUDIKERNEL_MESSAGE_H
4 
5 #include <string>
6 #include <iostream>
7 
16 public:
18  Message();
19 
21  Message ( const char* src, int type, const char* msg );
22 
24  Message ( const std::string& src, int type, const std::string& msg );
25 
27  ~Message() {}
28 
30  const std::string& getMessage() const;
31 
33  void setMessage( const std::string& msg );
34 
36  int getType() const;
37 
39  void setType( int msg_type );
40 
42  const std::string& getSource() const;
43 
45  void setSource( const std::string& src );
46 
48  const std::string& getFormat() const;
49 
51  static const std::string getDefaultFormat();
52 
54  void setFormat( const std::string& msg ) const;
55 
57  const std::string& getTimeFormat() const;
58 
60  static const std::string getDefaultTimeFormat() ;
61 
63  void setTimeFormat( const std::string& timeFormat ) const;
64 
66  bool operator < ( const Message& test );
67 
69  friend std::ostream& operator << ( std::ostream& stream, const Message& msg );
70 
72  friend bool operator == ( const Message& a, const Message& b );
73 
74 protected:
76  void invalidFormat() const;
77 
79  void makeFormattedMsg( const std::string& format ) const;
80 
82  void decodeFormat( const std::string& format ) const;
83 
85  void sizeField( const std::string& text ) const;
86 
88  void setWidth( const std::string& formatArg ) const;
89 
91  std::string m_message;
92 
94  std::string m_source;
95 
97  mutable std::string m_format;
98 
100  mutable std::string m_time_format;
101 
103  int m_type;
104 
106  mutable std::string m_formatted_msg;
107 
109  mutable char m_fill;
110 
112  mutable int m_width;
113 
115  mutable bool m_left;
116 
118  static const char FORMAT_PREFIX;
119 
121  static const char JUSTIFY_LEFT;
122 
124  static const char JUSTIFY_RIGHT;
125 
127  static const char MESSAGE;
128 
130  static const char TYPE;
131 
133  static const char TIME;
134 
137  static const char UTIME;
138 
140  static const char SOURCE;
141 
145  static const char FILL;
146 
150  static const char WIDTH;
151 
153  static const char* DEFAULT_FORMAT;
154 
156  static const char* DEFAULT_TIME_FORMAT;
157 
158 };
159 
161 GAUDI_API std::ostream& operator << ( std::ostream& stream, const Message& msg );
162 
164 GAUDI_API bool operator == ( const Message& a, const Message& b );
165 
166 #endif
static const char TYPE
The character used to indicate that the message type should be printed.
Definition: Message.h:130
bool m_left
Justification.
Definition: Message.h:115
static const char MESSAGE
The character used to indicate that the message should be printed.
Definition: Message.h:127
char m_fill
The current fill character.
Definition: Message.h:109
static const char JUSTIFY_LEFT
The character used to indicate start of left text justification.
Definition: Message.h:121
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:133
std::string m_formatted_msg
Formatted message.
Definition: Message.h:106
std::string m_time_format
Time format string.
Definition: Message.h:100
std::string m_message
The message.
Definition: Message.h:91
static const char * DEFAULT_FORMAT
The default message format.
Definition: Message.h:153
string type
Definition: gaudirun.py:126
static const char * DEFAULT_TIME_FORMAT
The default time format.
Definition: Message.h:156
~Message()
Default destructor.
Definition: Message.h:27
int m_width
The current field width.
Definition: Message.h:112
static const char TIME
The character used to indicate that the message timestamp should be printed.
Definition: Message.h:133
std::string m_format
The format string.
Definition: Message.h:97
static const char JUSTIFY_RIGHT
The character used to indicate start of right text justification.
Definition: Message.h:124
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Message &msg)
Insert the message into a stream.
Definition: Message.cpp:150
static const char UTIME
The character used to indicate that the message timestamp should be printed in UTC time...
Definition: Message.h:137
The Message class.
Definition: Message.h:15
GAUDI_API bool operator==(const Message &a, const Message &b)
Insert the message into a stream.
Definition: Message.cpp:176
static const char FILL
The character used to indicate that the previous character is to be used for padding out fields if th...
Definition: Message.h:145
bool operator<(const Gaudi::Time &t1, const Gaudi::Time &t2)
Definition: Time.icpp:233
static const char FORMAT_PREFIX
The character used to prefix formatting commands.
Definition: Message.h:118
#define GAUDI_API
Definition: Kernel.h:108
std::string m_source
The source.
Definition: Message.h:94
static const char WIDTH
The character used to indicate that the previous decimal characters should be taken as the field widt...
Definition: Message.h:150
static const char SOURCE
The character used to indicate that the message source should be printed.
Definition: Message.h:140
int m_type
The type.
Definition: Message.h:103