source: trunk/FACT++/src/MessageImp.h@ 10278

Last change on this file since 10278 was 10183, checked in by tbretz, 14 years ago
New import.
File size: 2.4 KB
Line 
1#ifndef FACT_MessageImp
2#define FACT_MessageImp
3
4#include <string>
5#include <sstream>
6#include <iostream>
7
8class Time;
9
10class MessageImp
11{
12public:
13 /// Severity of a message
14 enum Severity
15 {
16 kMessage = 10, ///< Just a message, usually obsolete
17 kInfo = 20, ///< An info telling something which can be interesting to know
18 kWarn = 30, ///< A warning, things that somehow might result in unexpected or unwanted bahaviour
19 kError = 40, ///< Error, something unexpected happened, but can still be handled by the program
20 kFatal = 50, ///< An error which cannot be handled at all happend, the only solution is program termination
21 kDebug = 99, ///< A message used for debugging only
22 };
23
24private:
25 std::ostream &fOut; /// The ostream to which by default Write redirects its output
26
27public:
28 MessageImp(std::ostream &out=std::cout);
29
30 virtual int Write(const Time &time, const char *txt, int qos=kInfo);
31
32 int Update(const char *txt, int qos=kInfo);
33 int Update(const std::string &str, int qos=kInfo) { return Update(str.c_str(), qos); }
34 int Update(const std::stringstream &str, int qos=kInfo) { return Update(str.str(), qos); }
35 int Update(int qos, const char *fmt, ...);
36
37 int Message(const char *txt) { return Update(txt, kMessage); }
38 int Info(const char *txt) { return Update(txt, kInfo); }
39 int Warn(const char *txt) { return Update(txt, kWarn); }
40 int Error(const char *txt) { return Update(txt, kError); }
41 int Fatal(const char *txt) { return Update(txt, kFatal); }
42
43 int Message(const std::string &str) { return Message(str.c_str()); }
44 int Info(const std::string &str) { return Info(str.c_str()); }
45 int Warn(const std::string &str) { return Warn(str.c_str()); }
46 int Error(const std::string &str) { return Error(str.c_str()); }
47 int Fatal(const std::string &str) { return Fatal(str.c_str()); }
48
49 int Message(const std::stringstream &str) { return Message(str.str()); }
50 int Info(const std::stringstream &str) { return Info(str.str()); }
51 int Warn(const std::stringstream &str) { return Warn(str.str()); }
52 int Error(const std::stringstream &str) { return Error(str.str()); }
53 int Fatal(const std::stringstream &str) { return Fatal(str.str()); }
54
55 std::ostream &operator()() { return fOut; }
56 std::ostream &Out() { return fOut; }
57};
58
59#endif
Note: See TracBrowser for help on using the repository browser.