00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CONSOLE_HPP
00021 #define CONSOLE_HPP
00022
00023 #include <Stringify.hpp>
00024 #include <ThreadStaticBase.hpp>
00025
00026 #include <string>
00027
00028 #include <config.h>
00029
00030 #ifdef HAVE_GUI_LIBS
00031 class QTextEdit;
00032 #endif // HAVE_GUI_LIBS
00033
00034 class Console
00035 : public ThreadStaticBase<Console>
00036 {
00037 private:
00038 #ifdef HAVE_GUI_LIBS
00039 QTextEdit* __console;
00040 #endif // HAVE_GUI_LIBS
00041
00042 std::stringstream* __std_buffer;
00043 std::stringstream* __error_buffer;
00044
00045 void _writeStd(std::string output);
00046 void _writeError(std::string output);
00047
00048 public:
00049 #ifdef HAVE_GUI_LIBS
00050 void setConsole(QTextEdit* console);
00051 #endif // HAVE_GUI_LIBS
00052
00053 template <typename T>
00054 void writeStd(const T& t)
00055 {
00056 this->_writeStd(stringify(t));
00057 }
00058
00059 template <typename T>
00060 void writeError(const T& t)
00061 {
00062 this->_writeError(stringify(t));
00063 }
00064
00065 Console();
00066 ~Console();
00067 };
00068
00069 #endif // CONSOLE_HPP