| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Message.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_MESSAGE_H
2 #define GAUDIKERNEL_MESSAGE_H
3
4 #include "GaudiKernel/Kernel.h" // for GAUDI_API
5 #include <iostream>
6 #include <string>
7
15 class GAUDI_API Message final
16 {
17 public:
19 Message();
20
22 Message( const char* src, int type, const char* msg );
23
25 Message( std::string src, int type, std::string msg );
26
28 ~Message() = default;
29
31 const std::string& getMessage() const;
32
34 void setMessage( std::string msg );
35
37 int getType() const;
38
40 void setType( int msg_type );
41
43 const std::string& getSource() const;
44
46 void setSource( std::string src );
47
49 const std::string& getFormat() const;
50
52 static const std::string getDefaultFormat();
53
55 void setFormat( std::string msg ) const;
56
58 const std::string& getTimeFormat() const;
59
61 static const std::string getDefaultTimeFormat();
62
64 void setTimeFormat( std::string timeFormat ) const;
65
67 bool operator<( const Message& test );
68
70 friend std::ostream& operator<<( std::ostream& stream, const Message& msg );
71
73 friend bool operator==( const Message& a, const Message& b );
74
75 private:
77 void invalidFormat() const;
78
80 void makeFormattedMsg( const std::string& format ) const;
81
83 void decodeFormat( const std::string& format ) const;
84
86 void sizeField( const std::string& text ) const;
87
89 void setWidth( const std::string& formatArg ) const;
90
92 std::string m_message;
93
95 std::string m_source = "UNKNOWN";
96
98 mutable std::string m_format = DEFAULT_FORMAT;
99
101 mutable std::string m_time_format = DEFAULT_TIME_FORMAT;
102
104 int m_type = 0;
105
107 mutable std::string m_formatted_msg;
108
110 mutable char m_fill = ' ';
111
113 mutable int m_width = 0;
114
116 mutable bool m_left = true;
117
119
121 static const char FORMAT_PREFIX = '%';
122
124 static const char JUSTIFY_LEFT = 'L';
125
127 static const char JUSTIFY_RIGHT = 'R';
128
130 static const char MESSAGE = 'M';
131
133 static const char TYPE = 'T';
134
136 static const char TIME = 't';
137
140 static const char UTIME = 'u';
141
143 static const char SOURCE = 'S';
144
148 static const char FILL = 'F';
149
153 static const char WIDTH = 'W';
154
156 // static const char* Message::DEFAULT_FORMAT = "%
157 // F%67W%L#############################################################################\n-----------------------------------------------------------------------------\nMessage
158 // follows...\nSource : %S\nType : %T\nMessage : %M\nEnd of
159 // message.\n-----------------------------------------------------------------------------\n";
160 static constexpr const char* DEFAULT_FORMAT = "% F%18W%S%7W%R%T %0W%M";
161
163 // Time format accepts anything that strftime does plus %f for milliseconds
164 static constexpr const char* DEFAULT_TIME_FORMAT = "%Y-%m-%d %H:%M:%S,%f";
165
167 static const char SLOT = 's';
168 static const char EVTNUM = 'e';
169 static const char THREAD = 'X';
170
171 size_t m_ecSlot;
172 long int m_ecEvt;
173 pthread_t m_ecThrd;
174 };
175
177 GAUDI_API std::ostream& operator<<( std::ostream& stream, const Message& msg );
178
180 GAUDI_API bool operator==( const Message& a, const Message& b );
181
182 #endif
Message::m_ecSlot
size_t m_ecSlot
Definition: Message.h:171
Message::m_ecEvt
long int m_ecEvt
Definition: Message.h:172
Kernel.h
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
Message::m_formatted_msg
std::string m_formatted_msg
Formatted message.
Definition: Message.h:107
Message::m_message
std::string m_message
The message.
Definition: Message.h:92
std::string
STL class.
compareRootHistos.test
string test
Definition: compareRootHistos.py:15
gaudirun.type
type
Definition: gaudirun.py:133
operator<
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:206
operator<<
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Message &msg)
Insert the message into a stream.
Definition: Message.cpp:119
Message
The Message class.
Definition: Message.h:15
Message::m_ecThrd
pthread_t m_ecThrd
Definition: Message.h:173
operator==
GAUDI_API bool operator==(const Message &a, const Message &b)
Insert the message into a stream.
Definition: Message.cpp:143
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
std::ostream
STL class.